mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Merge remote-tracking branch 'origin/support/3.2' into develop
This commit is contained in:
@@ -38,12 +38,13 @@ final class Psr4DirectoryLoader extends Loader implements DirectoryAwareLoaderIn
|
||||
*/
|
||||
public function load(mixed $resource, ?string $type = null): ?RouteCollection
|
||||
{
|
||||
$excluded = $resource['_excluded'] ?? [];
|
||||
$path = $this->locator->locate($resource['path'], $this->currentDirectory);
|
||||
if (!is_dir($path)) {
|
||||
return new RouteCollection();
|
||||
}
|
||||
|
||||
return $this->loadFromDirectory($path, trim($resource['namespace'], '\\'));
|
||||
return $this->loadFromDirectory($path, trim($resource['namespace'], '\\'), $excluded);
|
||||
}
|
||||
|
||||
public function supports(mixed $resource, ?string $type = null): bool
|
||||
@@ -59,7 +60,7 @@ final class Psr4DirectoryLoader extends Loader implements DirectoryAwareLoaderIn
|
||||
return $loader;
|
||||
}
|
||||
|
||||
private function loadFromDirectory(string $directory, string $psr4Prefix): RouteCollection
|
||||
private function loadFromDirectory(string $directory, string $psr4Prefix, array $excluded = []): RouteCollection
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$collection->addResource(new DirectoryResource($directory, '/\.php$/'));
|
||||
@@ -74,8 +75,13 @@ final class Psr4DirectoryLoader extends Loader implements DirectoryAwareLoaderIn
|
||||
|
||||
/** @var \SplFileInfo $file */
|
||||
foreach ($files as $file) {
|
||||
$normalizedPath = rtrim(str_replace('\\', '/', $file->getPathname()), '/');
|
||||
if (isset($excluded[$normalizedPath])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($file->isDir()) {
|
||||
$collection->addCollection($this->loadFromDirectory($file->getPathname(), $psr4Prefix.'\\'.$file->getFilename()));
|
||||
$collection->addCollection($this->loadFromDirectory($file->getPathname(), $psr4Prefix.'\\'.$file->getFilename(), $excluded));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user