Skip to content

Commit ccefb3d

Browse files
[Routing] Fix "config-file-relative" annotation loader resources
1 parent 6f87ba9 commit ccefb3d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Loader/AnnotationDirectoryLoader.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
3434
*/
3535
public function load($path, $type = null)
3636
{
37-
$dir = $this->locator->locate($path);
37+
if (!is_dir($dir = $this->locator->locate($path))) {
38+
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
39+
}
3840

3941
$collection = new RouteCollection();
4042
$collection->addResource(new DirectoryResource($dir, '/\.php$/'));
@@ -74,16 +76,18 @@ function (\SplFileInfo $current) {
7476
*/
7577
public function supports($resource, $type = null)
7678
{
77-
if (!is_string($resource)) {
79+
if ('annotation' === $type) {
80+
return true;
81+
}
82+
83+
if ($type || !is_string($resource)) {
7884
return false;
7985
}
8086

8187
try {
82-
$path = $this->locator->locate($resource);
88+
return is_dir($this->locator->locate($resource));
8389
} catch (\Exception $e) {
8490
return false;
8591
}
86-
87-
return is_dir($path) && (!$type || 'annotation' === $type);
8892
}
8993
}

0 commit comments

Comments
 (0)