Skip to content

Commit 8c61857

Browse files
committed
bug #37102 [WebProfilerBundle] Fix error with custom function and web profiler routing tab (JakeFr)
This PR was merged into the 4.4 branch. Discussion ---------- [WebProfilerBundle] Fix error with custom function and web profiler routing tab | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36985 | License | MIT | Doc PR | no Here is a simple solution for #36985 as it only concerns WebProfilerBundle. Due to the limitation in the routing tab as explained in the footnote, the route in my repo did not match in profiler (no query string in the new context) but there is no more syntax error. Commits ------- b35c81becb fix error with custom function and web profiler routing tab
2 parents c946a25 + a086e18 commit 8c61857

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Controller/RouterController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\WebProfilerBundle\Controller;
1313

14+
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
1415
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
@@ -36,12 +37,18 @@ class RouterController
3637
private $matcher;
3738
private $routes;
3839

39-
public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null)
40+
/**
41+
* @var ExpressionFunctionProviderInterface[]
42+
*/
43+
private $expressionLanguageProviders = [];
44+
45+
public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null, iterable $expressionLanguageProviders = [])
4046
{
4147
$this->profiler = $profiler;
4248
$this->twig = $twig;
4349
$this->matcher = $matcher;
4450
$this->routes = (null === $routes && $matcher instanceof RouterInterface) ? $matcher->getRouteCollection() : $routes;
51+
$this->expressionLanguageProviders = $expressionLanguageProviders;
4552
}
4653

4754
/**
@@ -94,6 +101,9 @@ private function getTraces(RequestDataCollector $request, string $method): array
94101
$context = $this->matcher->getContext();
95102
$context->setMethod($method);
96103
$matcher = new TraceableUrlMatcher($this->routes, $context);
104+
foreach ($this->expressionLanguageProviders as $provider) {
105+
$matcher->addExpressionLanguageProvider($provider);
106+
}
97107

98108
return $matcher->getTracesForRequest($traceRequest);
99109
}

Resources/config/profiler.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<argument type="service" id="profiler" on-invalid="null" />
2121
<argument type="service" id="twig" />
2222
<argument type="service" id="router" on-invalid="null" />
23+
<argument>null</argument>
24+
<argument type="tagged_iterator" tag="routing.expression_language_provider" />
2325
</service>
2426

2527
<service id="web_profiler.controller.exception" class="Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController" public="true">

0 commit comments

Comments
 (0)