*/ class SiteRequest { protected RequestStack $requestStack; protected NodeRepository $nodeRepository; protected NavigationRepositoryQuery $navigationRepositoryQuery; protected PageRepositoryQuery $pageRepositoryQuery; public function __construct(RequestStack $requestStack, NodeRepository $nodeRepository) { $this->requestStack = $requestStack; $this->nodeRepository = $nodeRepository; } public function getNode(): ?Node { $request = $this->requestStack->getCurrentRequest(); if ($request->attributes->has('_node')) { return $this->nodeRepository->findOneBy([ 'id' => $request->attributes->get('_node'), ]); } return null; } public function getPage(): ?Page { $node = $this->getNode(); if ($node && $node->getPage()) { return $node->getPage(); } return null; } public function getMenu(): ?Menu { $node = $this->getNode(); return null !== $node ? $node->getMenu() : null; } public function getNavigation(): ?Navigation { $menu = $this->getMenu(); return null !== $menu ? $menu->getNavigation() : null; } }