Skip to content

Commit 473c605

Browse files
committed
Ref symfony#15: Added small comment + get context outside of foreach loop
1 parent 8fe672e commit 473c605

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ChainRouter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ public function all()
9191
if (empty($this->sortedRouters)) {
9292
$this->sortedRouters = $this->sortRouters();
9393

94+
// setContext() is done here instead of in add() to avoid fatal errors when clearing and warming up caches
95+
// See https://github.com/symfony-cmf/Routing/pull/18
9496
$context = $this->getContext();
95-
foreach ($this->sortedRouters as $router) {
96-
if ($router instanceof RequestContextAwareInterface) {
97-
if (null !== $context) {
97+
if (null !== $context) {
98+
foreach ($this->sortedRouters as $router) {
99+
if ($router instanceof RequestContextAwareInterface) {
98100
$router->setContext($context);
99101
}
100102
}

0 commit comments

Comments
 (0)