8000 Made the router lazy when setting the context · Ouark/symfony@e0a3fc1 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0a3fc1

Browse files
stoffabpot
authored andcommitted
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).
1 parent ee75975 commit e0a3fc1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Routing/Router.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Config\ConfigCache;
1616
use Symfony\Component\HttpKernel\Log\LoggerInterface;
1717
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
18+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
19+
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
1820

1921
/**
2022
* The Router class is an example of the integration of all pieces of the
@@ -150,8 +152,12 @@ public function setContext(RequestContext $context)
150152
{
151153
$this->context = $context;
152154

153-
$this->getMatcher()->setContext($context);
154-
$this->getGenerator()->setContext($context);
155+
if (null !== $this->matcher) {
156+
$this->getMatcher()->setContext($context);
157+
}
158+
if (null !== $this->generator) {
159+
$this->getGenerator()->setContext($context);
160+
}
155161
}
156162

157163
/**

0 commit comments

Comments
 (0)
0