ServiceRouterLoader.php 919 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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\DependencyInjection;
  11. use Psr\Container\ContainerInterface;
  12. use Symfony\Component\Routing\Loader\ObjectRouteLoader;
  13. /**
  14. * A route loader that executes a service to load the routes.
  15. *
  16. * This depends on the DependencyInjection component.
  17. *
  18. * @author Ryan Weaver <ryan@knpuniversity.com>
  19. */
  20. class ServiceRouterLoader extends ObjectRouteLoader
  21. {
  22. /**
  23. * @var ContainerInterface
  24. */
  25. private $container;
  26. public function __construct(ContainerInterface $container)
  27. {
  28. $this->container = $container;
  29. }
  30. protected function getServiceObject($id)
  31. {
  32. return $this->container->get($id);
  33. }
  34. }