protected function CommentPermissions::buildPermissions in Comment Permissions 8
Returns a list of node permissions for a given node type.
Parameters
\Drupal\comment\Entity\CommentType $type: The comment type.
Return value
array An associative array of permission names and descriptions.
1 call to CommentPermissions::buildPermissions()
- CommentPermissions::commentTypePermissions in src/
CommentPermissions.php - Returns an array of comment type permissions.
File
- src/
CommentPermissions.php, line 41
Class
- CommentPermissions
- Provide dynamic permissions for comments of different types.
Namespace
Drupal\comment_permCode
protected function buildPermissions(CommentType $type) {
$type_id = $type
->id();
$type_params = array(
'%type_name' => $type
->label(),
);
return array(
"administer {$type_id} comments" => array(
'title' => $this
->t('%type_name: Administer comments and comment settings', $type_params),
),
"administer {$type_id} comment type" => array(
'title' => $this
->t('%type_name: Administer comment type and settings', $type_params),
'restrict access' => TRUE,
),
"access {$type_id} comments" => array(
'title' => $this
->t('%type_name: View comments', $type_params),
),
"post {$type_id} comments" => array(
'title' => $this
->t('%type_name: Post comments', $type_params),
),
"skip {$type_id} comment approval" => array(
'title' => $this
->t('%type_name: Skip comment approval', $type_params),
),
"edit {$type_id} own comments" => array(
'title' => $this
->t('%type_name: Edit own comments', $type_params),
),
);
}