public function CommentAccessTrait::accessComment 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.
3 calls to CommentAccessTrait::accessComment()
- 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.
- CommentLinkBuilder::buildCommentedEntityLinks in src/
CommentLinkBuilder.php - Builds links for the given entity.
File
- src/
CommentAccessTrait.php, line 80
Class
- CommentAccessTrait
- Class CommentAccessTrait
Namespace
Drupal\comment_permCode
public function accessComment(AccountInterface $account, $comment_type) {
if ($account
->hasPermission('access comments') || $account
->hasPermission("access {$comment_type} comments")) {
return TRUE;
}
return FALSE;
}