src/Kunstmaan/NodeBundle/EventListener/SlugSecurityListener.php
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);
    }
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);
    }
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 ) ; }
Perform basic security checks

@param SlugSecurityEvent $event

@throws AccessDeniedException
@throws NotFoundHttpException
Perform basic security checks