예제 #1
0
 /**
  * @param Comment $comment
  * @return bool
  */
 private function userHasAccess(Comment $comment)
 {
     if ($comment->getUser() == $this->getUser() || $this->get('security.context')->isGranted('ROLE_ADMIN')) {
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * @param Comment $comment
  * @return bool
  */
 public function isCommentAuthor(Comment $comment)
 {
     $commentAuthor = $comment->getUser();
     $user = $this->container->get('security.context')->getToken()->getUser();
     $isGranted = $this->container->get('security.context')->isGranted('ROLE_ADMIN');
     if ($commentAuthor == $user || $isGranted) {
         return true;
     }
     return false;
 }