You are here

protected function MediaPermissions::buildPermissions in Drupal 8

Same name and namespace in other branches
  1. 9 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),
    ],
  ];
}