Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
32 * | 32 * |
33 * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed | 33 * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed |
34 */ | 34 */ |
35 public function load($path, $type = null) | 35 public function load($path, $type = null) |
36 { | 36 { |
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 } | |
38 | 40 |
39 $collection = new RouteCollection(); | 41 $collection = new RouteCollection(); |
40 $collection->addResource(new DirectoryResource($dir, '/\.php$/')); | 42 $collection->addResource(new DirectoryResource($dir, '/\.php$/')); |
41 $files = iterator_to_array(new \RecursiveIteratorIterator( | 43 $files = iterator_to_array(new \RecursiveIteratorIterator( |
42 new \RecursiveCallbackFilterIterator( | 44 new \RecursiveCallbackFilterIterator( |
43 new \RecursiveDirectoryIterator($dir), | 45 new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), |
44 function (\SplFileInfo $current) { | 46 function (\SplFileInfo $current) { |
45 return '.' !== substr($current->getBasename(), 0, 1); | 47 return '.' !== substr($current->getBasename(), 0, 1); |
46 } | 48 } |
47 ), | 49 ), |
48 \RecursiveIteratorIterator::LEAVES_ONLY | 50 \RecursiveIteratorIterator::LEAVES_ONLY |
72 /** | 74 /** |
73 * {@inheritdoc} | 75 * {@inheritdoc} |
74 */ | 76 */ |
75 public function supports($resource, $type = null) | 77 public function supports($resource, $type = null) |
76 { | 78 { |
77 if (!is_string($resource)) { | 79 if ('annotation' === $type) { |
80 return true; | |
81 } | |
82 | |
83 if ($type || !is_string($resource)) { | |
78 return false; | 84 return false; |
79 } | 85 } |
80 | 86 |
81 try { | 87 try { |
82 $path = $this->locator->locate($resource); | 88 return is_dir($this->locator->locate($resource)); |
83 } catch (\Exception $e) { | 89 } catch (\Exception $e) { |
84 return false; | 90 return false; |
85 } | 91 } |
86 | |
87 return is_dir($path) && (!$type || 'annotation' === $type); | |
88 } | 92 } |
89 } | 93 } |