/**
  * Perform basic security checks
  *
  * @param SlugSecurityEvent $event
  *
  * @throws AccessDeniedException
  * @throws NotFoundHttpException
  */
 public function onSlugSecurityEvent(SlugSecurityEvent $event)
 {
     $node = $event->getNode();
     $nodeTranslation = $event->getNodeTranslation();
     $request = $event->getRequest();
     /* @var SecurityContextInterface $securityContext */
     if (false === $this->securityContext->isGranted(PermissionMap::PERMISSION_VIEW, $node)) {
         throw new AccessDeniedException('You do not have sufficient rights to access this page.');
     }
     $isPreview = $request->attributes->get('preview');
     if (!$isPreview && !$nodeTranslation->isOnline()) {
         throw new NotFoundHttpException('The requested page is not online');
     }
 }
 /**
  *
  */
 public function onSlugSecurityEvent(SlugSecurityEvent $event)
 {
     $node = $event->getNode();
     $nodeTranslation = $event->getNodeTranslation();
     $request = $event->getRequest();
     /* @var SecurityContextInterface $securityContext */
     if (false === $this->securityContext->isGranted(PermissionMap::PERMISSION_VIEW, $node)) {
         throw new AccessDeniedException('You do not have sufficient rights to access this page.');
     }
     $locale = $request->attributes->get('_locale');
     $preview = $request->attributes->get('preview');
     // check if the requested node is online, else throw a 404 exception (only when not previewing!)
     if (!$preview && !$nodeTranslation->isOnline()) {
         throw new NotFoundHttpException("The requested page is not online");
     }
     $nodeMenu = new NodeMenu($this->em, $this->securityContext, $this->acl, $locale, $node, PermissionMap::PERMISSION_VIEW, $preview);
     $request->attributes->set('_nodeMenu', $nodeMenu);
 }
 /**
  * Perform basic security checks
  *
  * @param SlugSecurityEvent $event
  *
  * @throws AccessDeniedException
  * @throws NotFoundHttpException
  */
 public function onSlugSecurityEvent(SlugSecurityEvent $event)
 {
     $node = $event->getNode();
     $nodeTranslation = $event->getNodeTranslation();
     $request = $event->getRequest();
     if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_VIEW, $node)) {
         throw new AccessDeniedException('You do not have sufficient rights to access this page.');
     }
     $isPreview = $request->attributes->get('preview');
     if (!$isPreview && !$nodeTranslation->isOnline()) {
         throw new NotFoundHttpException('The requested page is not online');
     }
     $nodeMenu = $this->nodeMenu;
     $nodeMenu->setLocale($nodeTranslation->getLang());
     $nodeMenu->setCurrentNode($node);
     $nodeMenu->setIncludeOffline($isPreview);
     $request->attributes->set('_nodeMenu', $nodeMenu);
 }