コード例 #1
0
 /**
  * Return a 404 Response or TRUE if node is viewable.
  *
  * @param  Node $node
  *
  * @return boolean|Symfony\Component\HttpFoundation\Response
  */
 public function validateAccessForNodeWithStatus(Node $node)
 {
     if (!$this->isGranted(Role::ROLE_BACKEND_USER) && !$node->isPublished()) {
         /*
          * Not allowed to see unpublished nodes
          */
         return $this->throw404();
     } elseif ($this->isGranted(Role::ROLE_BACKEND_USER) && $node->getStatus() > Node::PUBLISHED) {
         /*
          * Not allowed to see deleted and archived nodes
          * even for Admins
          */
         return $this->throw404();
     } else {
         return true;
     }
 }