merged branch stof/lazy_router (PR #5745)
This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes #5745). Commits ------- a6918ec Made the router lazy when setting the context Discussion ---------- Made the router lazy when setting the context Initializing the matcher and the generator to set the context does not make sense as it is set anyway when building them. This avoids initializing them in the RouterListener if you never actually use them (for instance because you use the apache matcher). @fabpot should it be considered as a bugfix (and so done in older branches) or a new feature ? --------------------------------------------------------------------------- by stof at 2012-10-14T01:23:51Z Btw, looking at the ApacheUrlMatcher code, I think it is flawed and that this change will actually not fix the performance issue reported in #5538 as it requires creating the RouteCollection everytime, including when apache actually matched it.
This commit is contained in:
commit
a88bb9b3de
@ -15,6 +15,8 @@ use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||
|
||||
/**
|
||||
* The Router class is an example of the integration of all pieces of the
|
||||
@ -150,8 +152,12 @@ class Router implements RouterInterface
|
||||
{
|
||||
$this->context = $context;
|
||||
|
||||
$this->getMatcher()->setContext($context);
|
||||
$this->getGenerator()->setContext($context);
|
||||
if (null !== $this->matcher) {
|
||||
$this->getMatcher()->setContext($context);
|
||||
}
|
||||
if (null !== $this->generator) {
|
||||
$this->getGenerator()->setContext($context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user