fix error with custom function and web profiler routing tab

This commit is contained in:
JakeFr 2020-06-03 15:41:40 +02:00
parent a2f4342d08
commit b35c81becb
2 changed files with 13 additions and 1 deletions

View File

@ -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);
}

View File

@ -20,6 +20,8 @@
<argument type="service" id="profiler" on-invalid="null" />
<argument type="service" id="twig" />
<argument type="service" id="router" on-invalid="null" />
<argument>null</argument>
<argument type="tagged_iterator" tag="routing.expression_language_provider" />
</service>
<service id="web_profiler.controller.exception" class="Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController" public="true">