/**
  * Determine whether or not the user has permission to submit a comment
  *
  * @param Content $content
  * @param User\UserInterface $user
  *
  * @return bool
  */
 public function userAllowed(Content $content, User\UserInterface $user)
 {
     $allowedGroups = $content->{ContentOptions::COMMENTS}->{ContentOptions::PERMISSION}->getValue();
     if ($user instanceof User\AnonymousUser) {
         return array_key_exists(ContentOptions::GUEST, $allowedGroups);
     }
     if (array_key_exists(ContentOptions::LOGGED_IN, $allowedGroups)) {
         return true;
     }
     $userGroups = $this->_groupLoader->getByUser($user);
     foreach ($userGroups as $userGroup) {
         if (array_key_exists($userGroup->getName(), $allowedGroups)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Set the status of the comment, depending on the configuration of the blog post, and who is making the comment.
  * A super admin's comment will always be approved right away
  *
  * @param Comment $comment
  * @param Content $content
  *
  * @return Comment
  */
 private function _setStatus(Comment $comment, Content $content)
 {
     if (!$this->_user instanceof AnonymousUser) {
         $userGroups = $this->_userGroupLoader->getByUser($this->_user);
         foreach ($userGroups as $group) {
             if ($group->getName() === 'ms-super-admin') {
                 $comment->setStatus(Statuses::APPROVED);
                 return $comment;
             }
         }
     }
     $allowed = $content->{ContentOptions::COMMENTS}->{ContentOptions::ALLOW_COMMENTS}->getValue();
     $comment->setStatus($allowed === ContentOptions::APPROVE ? Statuses::PENDING : Statuses::APPROVED);
     return $comment;
 }