Keine Beschreibung

GlobFileLoader.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Routing\Loader;
  11. use Symfony\Component\Config\Loader\FileLoader;
  12. use Symfony\Component\Routing\RouteCollection;
  13. /**
  14. * GlobFileLoader loads files from a glob pattern.
  15. *
  16. * @author Nicolas Grekas <p@tchwork.com>
  17. */
  18. class GlobFileLoader extends FileLoader
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function load($resource, $type = null)
  24. {
  25. $collection = new RouteCollection();
  26. foreach ($this->glob($resource, false, $globResource) as $path => $info) {
  27. $collection->addCollection($this->import($path));
  28. }
  29. $collection->addResource($globResource);
  30. return $collection;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function supports($resource, $type = null)
  36. {
  37. return 'glob' === $type;
  38. }
  39. }