*/
public function load($path, $type = null)
{
- $dir = $this->locator->locate($path);
+ if (!is_dir($dir = $this->locator->locate($path))) {
+ return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
+ }
$collection = new RouteCollection();
$collection->addResource(new DirectoryResource($dir, '/\.php$/'));
$files = iterator_to_array(new \RecursiveIteratorIterator(
new \RecursiveCallbackFilterIterator(
- new \RecursiveDirectoryIterator($dir),
+ new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
function (\SplFileInfo $current) {
return '.' !== substr($current->getBasename(), 0, 1);
}
*/
public function supports($resource, $type = null)
{
- if (!is_string($resource)) {
+ if ('annotation' === $type) {
+ return true;
+ }
+
+ if ($type || !is_string($resource)) {
return false;
}
try {
- $path = $this->locator->locate($resource);
+ return is_dir($this->locator->locate($resource));
} catch (\Exception $e) {
return false;
}
-
- return is_dir($path) && (!$type || 'annotation' === $type);
}
}