function BlockContentPermissions::buildPermissions

Same name in other branches
  1. 11.x core/modules/block_content/src/BlockContentPermissions.php \Drupal\block_content\BlockContentPermissions::buildPermissions()

Return all the permissions available for a block type.

Parameters

\Drupal\block_content\Entity\BlockContentType $type: The block type.

Return value

array Permissions available for the given block type.

File

core/modules/block_content/src/BlockContentPermissions.php, line 59

Class

BlockContentPermissions
Provide dynamic permissions for blocks of different types.

Namespace

Drupal\block_content

Code

protected function buildPermissions(BlockContentType $type) {
    $type_id = $type->id();
    $type_params = [
        '%type_name' => $type->label(),
    ];
    return [
        "create {$type_id} block content" => [
            'title' => $this->t('%type_name: Create new content block', $type_params),
        ],
        "edit any {$type_id} block content" => [
            'title' => $this->t('%type_name: Edit content block', $type_params),
        ],
        "delete any {$type_id} block content" => [
            'title' => $this->t('%type_name: Delete content block', $type_params),
        ],
        "view any {$type_id} block content history" => [
            'title' => $this->t('%type_name: View content block history pages', $type_params),
        ],
        "revert any {$type_id} block content revisions" => [
            'title' => $this->t('%type_name: Revert content block revisions', $type_params),
        ],
        "delete any {$type_id} block content revisions" => [
            'title' => $this->t('%type_name: Delete content block revisions', $type_params),
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.