/**
  * Check if the node on the event is published, otherwise skip it.
  *
  * @param CreateMenuItemFromNodeEvent $event
  */
 public function onCreateMenuItemFromNode(CreateMenuItemFromNodeEvent $event)
 {
     $node = $event->getNode();
     if (!$this->publishWorkflowChecker->isGranted($this->publishWorkflowPermission, $node)) {
         $event->setSkipNode(true);
     }
 }
 /**
  * Determines if a node should be skipped from rendering based on the current
  * user's role
  *
  * @param CreateMenuItemFromNodeEvent $event
  */
 public function onCreateMenuItemFromNode(CreateMenuItemFromNodeEvent $event)
 {
     $node = $event->getNode();
     if ($node instanceof MenuNode) {
         $addRole = $node->getAddWhenGranted();
         $removeRole = $node->getRemoveWhenGranted();
         //This avoids issue when rendering error pages with menus
         //Defaults all menu items with any role requirements to no be displayed
         if ($this->token->getToken() === null) {
             if ($addRole !== null || $removeRole !== null) {
                 $event->setSkipNode(true);
             }
             return;
         }
         if ($addRole !== null) {
             if (!$this->security->isGranted($addRole)) {
                 $event->setSkipNode(true);
             }
         }
         if ($removeRole !== null) {
             if ($this->security->isGranted($removeRole)) {
                 $event->setSkipNode(true);
             }
         }
     }
 }