4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Loader;
14 use Symfony\Component\Config\Loader\FileLoader;
15 use Symfony\Component\Routing\RouteCollection;
16 use Symfony\Component\Config\Resource\DirectoryResource;
18 class DirectoryLoader extends FileLoader
23 public function load($file, $type = null)
25 $path = $this->locator->locate($file);
27 $collection = new RouteCollection();
28 $collection->addResource(new DirectoryResource($path));
30 foreach (scandir($path) as $dir) {
31 if ('.' !== $dir[0]) {
32 $this->setCurrentDir($path);
33 $subPath = $path.'/'.$dir;
36 if (is_dir($subPath)) {
38 $subType = 'directory';
41 $subCollection = $this->import($subPath, $subType, false, $path);
42 $collection->addCollection($subCollection);
52 public function supports($resource, $type = null)
54 // only when type is forced to directory, not to conflict with AnnotationLoader
56 return 'directory' === $type;