function MediaPermissions::buildPermissions

Same name in other branches
  1. 9 core/modules/media/src/MediaPermissions.php \Drupal\media\MediaPermissions::buildPermissions()
  2. 10 core/modules/media/src/MediaPermissions.php \Drupal\media\MediaPermissions::buildPermissions()
  3. 11.x core/modules/media/src/MediaPermissions.php \Drupal\media\MediaPermissions::buildPermissions()

Returns a list of media permissions for a given media type.

Parameters

\Drupal\media\MediaTypeInterface $type: The media type.

Return value

array An associative array of permission names and descriptions.

1 call to MediaPermissions::buildPermissions()
MediaPermissions::mediaTypePermissions in core/modules/media/src/MediaPermissions.php
Returns an array of media type permissions.

File

core/modules/media/src/MediaPermissions.php, line 69

Class

MediaPermissions
Provides dynamic permissions for each media type.

Namespace

Drupal\media

Code

protected function buildPermissions(MediaTypeInterface $type) {
    $type_id = $type->id();
    $type_params = [
        '%type_name' => $type->label(),
    ];
    return [
        "create {$type_id} media" => [
            'title' => $this->t('%type_name: Create new media', $type_params),
        ],
        "edit own {$type_id} media" => [
            'title' => $this->t('%type_name: Edit own media', $type_params),
        ],
        "edit any {$type_id} media" => [
            'title' => $this->t('%type_name: Edit any media', $type_params),
        ],
        "delete own {$type_id} media" => [
            'title' => $this->t('%type_name: Delete own media', $type_params),
        ],
        "delete any {$type_id} media" => [
            'title' => $this->t('%type_name: Delete any media', $type_params),
        ],
    ];
}

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