Source of file DelegatingLoader.php
Size: 2,216 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Routing; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Component\Config\Loader\DelegatingLoader as BaseDelegatingLoader; use Symfony\Component\Config\Loader\LoaderResolverInterface; use Psr\Log\LoggerInterface; /** * DelegatingLoader delegates route loading to other loaders using a loader resolver. * * This implementation resolves the _controller attribute from the short notation * to the fully-qualified form (from a:b:c to class:method). * * @author Fabien Potencier <fabien@symfony.com> */ class DelegatingLoader extends BaseDelegatingLoader { protected $parser; protected $logger; /** * Constructor. * * @param ControllerNameParser $parser A ControllerNameParser instance * @param LoggerInterface $logger A LoggerInterface instance * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance */ public function __construct(ControllerNameParser $parser, LoggerInterface $logger = null, LoaderResolverInterface $resolver) { $this->parser = $parser; $this->logger = $logger; parent::__construct($resolver); } /** * Loads a resource. * * @param mixed $resource A resource * @param string $type The resource type * * @return RouteCollection A RouteCollection instance */ public function load($resource, $type = null) { $collection = parent::load($resource, $type); foreach ($collection->all() as $route) { if ($controller = $route->getDefault('_controller')) { try { $controller = $this->parser->parse($controller); } catch (\Exception $e) { // unable to optimize unknown notation } $route->setDefault('_controller', $controller); } } return $collection; } } |