You are here

public function CommentAccessTrait::accessPostComment in Comment Permissions 8

Check if user has access to comments.

Parameters

\Drupal\Core\Session\AccountInterface $account: User account proxy.

$comment_type: Comment entity type.

Return value

bool TRUE user has access to view comments, FALSE otherwise.

6 calls to CommentAccessTrait::accessPostComment()
CommentAccess::replyFormAccess in src/Access/CommentAccess.php
Access check for the reply form.
CommentDefaultFormatter::viewElements in src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
Builds a renderable array for a field value.
CommentFieldItemList::access in src/CommentFieldItemList.php
Checks data value access.
CommentForm::save in src/CommentForm.php
Form submission handler for the 'save' action.
CommentLinkBuilder::buildCommentedEntityLinks in src/CommentLinkBuilder.php
Builds links for the given entity.

... See full list

File

src/CommentAccessTrait.php, line 99

Class

CommentAccessTrait
Class CommentAccessTrait

Namespace

Drupal\comment_perm

Code

public function accessPostComment(AccountInterface $account, $comment_type) {
  if ($account
    ->hasPermission('post comments') || $account
    ->hasPermission("post {$comment_type} comments")) {
    return TRUE;
  }
  return FALSE;
}