diff --git a/src/Bridge/Item/RequestAttributesContainer.php b/src/Bridge/Item/RequestAttributesContainer.php index e78900f..0c9065f 100644 --- a/src/Bridge/Item/RequestAttributesContainer.php +++ b/src/Bridge/Item/RequestAttributesContainer.php @@ -22,8 +22,12 @@ public function __construct(RequestStack $requestStack) $this->request = $requestStack->getMasterRequest(); } - public function get(string $name, string $default = null): string + public function get(string $name, string $default = ''): string { + if (!$this->request) { + return ''; + } + return $this->request->get($name, $default); } } diff --git a/src/Bridge/Matcher.php b/src/Bridge/Matcher.php index 5e8fdcd..ff6acb9 100644 --- a/src/Bridge/Matcher.php +++ b/src/Bridge/Matcher.php @@ -30,7 +30,7 @@ public function __construct(RequestStack $requestStack, UrlMatchVoterInterface $ public function isCurrent($item): bool { - if (!$item instanceof MatchableInterface) { + if (!$this->request || !$item instanceof MatchableInterface) { return false; }