From b35c81becb9eb7ccb97cce6d11559a87655db9fa Mon Sep 17 00:00:00 2001 From: JakeFr <> Date: Wed, 3 Jun 2020 15:41:40 +0200 Subject: [PATCH] fix error with custom function and web profiler routing tab --- .../Controller/RouterController.php | 12 +++++++++++- .../WebProfilerBundle/Resources/config/profiler.xml | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index cedcb9f9d4..4a93ec6567 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Controller; +use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; @@ -36,12 +37,18 @@ class RouterController private $matcher; private $routes; - public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null) + /** + * @var ExpressionFunctionProviderInterface[] + */ + private $expressionLanguageProviders = []; + + public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null, iterable $expressionLanguageProviders = []) { $this->profiler = $profiler; $this->twig = $twig; $this->matcher = $matcher; $this->routes = (null === $routes && $matcher instanceof RouterInterface) ? $matcher->getRouteCollection() : $routes; + $this->expressionLanguageProviders = $expressionLanguageProviders; } /** @@ -94,6 +101,9 @@ class RouterController $context = $this->matcher->getContext(); $context->setMethod($method); $matcher = new TraceableUrlMatcher($this->routes, $context); + foreach ($this->expressionLanguageProviders as $provider) { + $matcher->addExpressionLanguageProvider($provider); + } return $matcher->getTracesForRequest($traceRequest); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml index 89ecca5baf..c1c3c8a65e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml @@ -20,6 +20,8 @@ + null +