Merge remote-tracking branch 'origin/support/3.2' into develop

This commit is contained in:
lenaick.moreira
2026-03-02 10:56:31 +01:00
123 changed files with 2898 additions and 2149 deletions

View File

@@ -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;
}