1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\Routing\Loader;
13:
14: use Symfony\Component\Config\Loader\FileLoader;
15: use Symfony\Component\Routing\RouteCollection;
16: use Symfony\Component\Config\Resource\DirectoryResource;
17:
18: class DirectoryLoader extends FileLoader
19: {
20: 21: 22:
23: public function load($file, $type = null)
24: {
25: $path = $this->locator->locate($file);
26:
27: $collection = new RouteCollection();
28: $collection->addResource(new DirectoryResource($path));
29:
30: foreach (scandir($path) as $dir) {
31: if ('.' !== $dir[0]) {
32: $this->setCurrentDir($path);
33: $subPath = $path.'/'.$dir;
34: $subType = null;
35:
36: if (is_dir($subPath)) {
37: $subPath .= '/';
38: $subType = 'directory';
39: }
40:
41: $subCollection = $this->import($subPath, $subType, false, $path);
42: $collection->addCollection($subCollection);
43: }
44: }
45:
46: return $collection;
47: }
48:
49: 50: 51:
52: public function supports($resource, $type = null)
53: {
54:
55:
56: return 'directory' === $type;
57: }
58: }
59: