Skip to content
Snippets Groups Projects

Resolve #3408488 "Make unknownpathexcluder accept"

Compare and Show latest version
1 file
+ 4
7
Compare changes
  • Side-by-side
  • Inline
@@ -66,14 +66,12 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
* See \Drupal\package_manager\ComposerInspector::validate().
*/
public function excludeUnknownPaths(CollectPathsToExcludeEvent $event): void {
$known_paths = [];
$web_root = $this->pathLocator->getWebRoot();
// If the web root and project root are the same, there's nothing to do.
if (empty($web_root)) {
return;
}
$known_paths[] = $web_root;
$known_paths[] = [$web_root];
$project_root = $this->pathLocator->getProjectRoot();
// To determine the scaffold files to exclude, the installed packages must
@@ -113,17 +111,16 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
// glob() flags aren't supported on all systems. We also can't use
// \Drupal\Core\File\FileSystemInterface::scanDirectory(), because it
// unconditionally ignores hidden files and directories.
$unknown_paths = [];
$handle = opendir($project_root) ?: throw new \RuntimeException("Could not scan for files in the project root.");
while ($entry = readdir($handle)) {
if ($entry === '.' || $entry === '..' || in_array($entry, $known_paths, TRUE)) {
continue;
}
$unknown_paths[] = $entry;
// We can add the unknown path as-is, because it is relative to the
// project root.
$event->add($entry);
}
closedir($handle);
$event->addPathsRelativeToProjectRoot($unknown_paths);
}
/**
Loading