for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Everlution\NavigationBundle\Bridge;
use Everlution\Navigation\Builder\MatcherInterface;
use Everlution\Navigation\Item\MatchableInterface;
use Everlution\Navigation\Match\UrlMatchVoterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Class Matcher.
*
* @author Ivan Barlog <[email protected]>
*/
class Matcher implements MatcherInterface
{
/** @var UrlMatchVoterInterface */
private $voter;
/** @var Request */
private $request;
public function __construct(RequestStack $requestStack, UrlMatchVoterInterface $voter)
$this->request = $requestStack->getMainRequest();
$this->voter = $voter;
}
public function isCurrent($item): bool
if (!$this->request || !$item instanceof MatchableInterface) {
return false;
// we search matches within URL and route
foreach ([$this->request->getPathInfo(), $this->request->get('_route', '')] as $url) {
if ($this->voter->matches($url, $item)) {
return true;