Skip to content

Commit

Permalink
Merge branch '4.4' into 5.1
Browse files Browse the repository at this point in the history
* 4.4:
  fail properly when the required service is not defined
  Fix typo
  [Finder] Fix GitIgnore parser when dealing with (sub)directories and take order of lines into account
  Update UPGRADE-5.0.md
  Added the missing reset tag to mailer.logger_message_listener
  Updated README for the Mailer component
  fix error with custom function and web profiler routing tab
  • Loading branch information
fabpot committed Aug 6, 2020
2 parents 729d870 + 8c61857 commit 8d5c8c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Controller/RouterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -92,6 +99,9 @@ private function getTraces(RequestDataCollector $request, string $method): array
$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);
}
Expand Down
2 changes: 2 additions & 0 deletions Resources/config/profiler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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_panel" class="Symfony\Bundle\WebProfilerBundle\Controller\ExceptionPanelController" public="true">
Expand Down

0 comments on commit 8d5c8c4

Please sign in to comment.