diff -r 000000000000 -r 7f95f8617b0b vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,57 @@ + + * + * 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\Component\Routing\Router as BaseRouter; +use Symfony\Component\Routing\RequestContext; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * This Router only creates the Loader only when the cache is empty. + * + * @author Fabien Potencier + */ +class Router extends BaseRouter +{ + private $container; + + /** + * Constructor. + * + * @param ContainerInterface $container A ContainerInterface instance + * @param mixed $resource The main resource to load + * @param array $options An array of options + * @param RequestContext $context The context + * @param array $defaults The default values + */ + public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, array $defaults = array()) + { + $this->container = $container; + + $this->resource = $resource; + $this->context = null === $context ? new RequestContext() : $context; + $this->defaults = $defaults; + $this->setOptions($options); + } + + /** + * @{inheritdoc} + */ + public function getRouteCollection() + { + if (null === $this->collection) { + $this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']); + } + + return $this->collection; + } +}