* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Routing\Loader; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Config\Resource\DirectoryResource; /** * AnnotationDirectoryLoader loads routing information from annotations set * on PHP classes and methods. * * @author Fabien Potencier */ class AnnotationDirectoryLoader extends AnnotationFileLoader { /** * Loads from annotations from a directory. * * @param string $path A directory path * @param string|null $type The resource type * * @return RouteCollection A RouteCollection instance * * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed */ public function load($path, $type = null) { 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, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), function (\SplFileInfo $current) { return '.' !== substr($current->getBasename(), 0, 1); } ), \RecursiveIteratorIterator::LEAVES_ONLY )); usort($files, function (\SplFileInfo $a, \SplFileInfo $b) { return (string) $a > (string) $b ? 1 : -1; }); foreach ($files as $file) { if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) { continue; } if ($class = $this->findClass($file)) { $refl = new \ReflectionClass($class); if ($refl->isAbstract()) { continue; } $collection->addCollection($this->loader->load($class, $type)); } } return $collection; } /** * {@inheritdoc} */ public function supports($resource, $type = null) { if ('annotation' === $type) { return true; } if ($type || !is_string($resource)) { return false; } try { return is_dir($this->locator->locate($resource)); } catch (\Exception $e) { return false; } } } __halt_compiler();----SIGNATURE:----rjt+z3rU4M0bPnuIeSjxO+H67J9/FflqUrMzG9l5KKYYKdhBtAyVjfbD+J8bxvCTVHPfRhbv079XUItUQTUT0HY+f/STJbsX7meYLC2XH7KbAiVypUAtFq8jAyqDlXuORQM4KktRZc0P4BeH/n1ZZUNy/Ym3347hp+amS+P27TkCn800R4qWveH6DS/GGbud2ziwAs7fV8LRfIVn3gvu9qSQcD3UVry6tL6MRQeQQJqCofGFFDv+4kkIIQ2Q1YpEoyAZgdvfQmOkDa/gM2g0OInWxuUc2qUNtQDmtrAgrwlpvlh/iENopH4WPpTVx6cw1r4kk7ptSdKKOwZuxdnJTz0aTptVFH6fn+4rvX65r4yyBDTuBmVOBKAHf64SnuDfL2zZTcwkzNIkMTfbmqRtKW70YPEikOZBHyK6H4PveeqZqR1u5Iv3Q/+QhRn/6Vce4xuV0/Rn2QSWEe/T60VhYuv09ctH/JQyApW4KBXJHxqYnYH6pu1Upwx35Bmq32dyz+sGAjrnb041QifWOGVwK+koi45RHlsLi/TL0KC8I9XM3wGhZha6BgvYnpCHHD3A486funij94oLkS+g8qmltn65YjXj/e8tLSZJylazCjvM3kTuEPN1Q0LcXVHDivMPSwQ4Vs0j3KZM3Z78+Fsm2+50jFxfmPW8Ahd47NO5p4E=----ATTACHMENT:----OTE5MTc1MjAxNTUxOTY3MiA1Mzg0MzY0MDYzODQ4MDYzIDIzNDI5MDIxMDM1MDM5OTI=