Skip to content

Commit 6a5c942

Browse files
committed
allow exclude patterns for DI Directory Scanner
1 parent 94f3bec commit 6a5c942

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dev/tools/Magento/Tools/Di/Code/Scanner/DirectoryScanner.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class DirectoryScanner
1212
*
1313
* @param string $dir
1414
* @param array $patterns
15+
* @param string[] $excludePatterns
1516
* @return array
1617
*/
17-
public function scan($dir, array $patterns = [])
18+
public function scan($dir, array $patterns = [], array $excludePatterns = [])
1819
{
1920
$recursiveIterator = new \RecursiveIteratorIterator(
2021
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::FOLLOW_SYMLINKS)
@@ -27,6 +28,13 @@ public function scan($dir, array $patterns = [])
2728
}
2829

2930
$filePath = str_replace('\\', '/', $file->getRealPath());
31+
if (!empty($excludePatterns)) {
32+
foreach ($excludePatterns as $excludePattern) {
33+
if (preg_match($excludePattern, $filePath)) {
34+
continue 2;
35+
}
36+
}
37+
}
3038
foreach ($patterns as $type => $pattern) {
3139
if (preg_match($pattern, $filePath)) {
3240
$output[$type][] = $filePath;

0 commit comments

Comments
 (0)