You are here

protected function MediaPermissions::buildPermissions in Drupal 9

Same name and namespace in other branches
  1. 8 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.

File

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

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),
    ],
  ];
}