Skip to content
Snippets Groups Projects

Resolve #3408488 "Make unknownpathexcluder accept"

1 file
+ 11
14
Compare changes
  • Side-by-side
  • Inline
@@ -88,34 +88,31 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
$this->composerInspector->validate($project_root);
$vendor_dir = ltrim(str_replace($project_root, '', $this->pathLocator->getVendorDirectory()), '/');
$scaffold_files_paths = $this->getScaffoldFiles();
$include = [
$vendor_dir,
$web_root,
'composer.json',
'composer.lock',
...$this->getScaffoldFiles(),
];
// Search for all files (including hidden ones) in the project root. We need
// to use readdir() and friends here, rather than glob(), since certain
// 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.
$paths_in_project_root = [];
$handle = opendir($project_root);
if (empty($handle)) {
throw new \RuntimeException("Could not scan for files in the project root.");
}
while (($entry = readdir($handle)) !== FALSE) {
if ($entry === '.' || $entry === '..') {
while ($entry = readdir($handle)) {
if ($entry === '.' || $entry === '..' || in_array($entry, $include, TRUE)) {
continue;
}
$paths_in_project_root[] = $entry;
// We can add the path as-is; it's already relative to the project root.
$event->add($entry);
}
closedir($handle);
$paths = [];
$known_paths = array_merge([$vendor_dir, $web_root, "composer.json", "composer.lock"], $scaffold_files_paths);
foreach ($paths_in_project_root as $path_in_project_root) {
if (!in_array($path_in_project_root, $known_paths, TRUE)) {
$paths[] = $path_in_project_root;
}
}
$event->add(...$paths);
}
/**
Loading