You are here

protected function ReferencePermissions::buildPermissions in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_entity/src/ReferencePermissions.php \Drupal\bibcite_entity\ReferencePermissions::buildPermissions()

Returns a list of Reference permissions for a given type.

Parameters

\Drupal\bibcite_entity\Entity\ReferenceType $type: The reference type.

Return value

array An associative array of permission names and descriptions.

1 call to ReferencePermissions::buildPermissions()
ReferencePermissions::referenceTypePermissions in modules/bibcite_entity/src/ReferencePermissions.php
Returns an array of Reference type permissions.

File

modules/bibcite_entity/src/ReferencePermissions.php, line 42

Class

ReferencePermissions
Provides dynamic permissions for References of different types.

Namespace

Drupal\bibcite_entity

Code

protected function buildPermissions(ReferenceType $type) {
  $type_id = $type
    ->id();
  $type_params = [
    '%type_name' => $type
      ->label(),
  ];
  return [
    "create {$type_id} bibcite_reference" => [
      'title' => $this
        ->t('%type_name: Create new Reference entity', $type_params),
    ],
    "edit own {$type_id} bibcite_reference" => [
      'title' => $this
        ->t('%type_name: Edit own Reference entity', $type_params),
    ],
    "edit any {$type_id} bibcite_reference" => [
      'title' => $this
        ->t('%type_name: Edit any Reference entity', $type_params),
    ],
    "delete own {$type_id} bibcite_reference" => [
      'title' => $this
        ->t('%type_name: Delete own Reference entity', $type_params),
    ],
    "delete any {$type_id} bibcite_reference" => [
      'title' => $this
        ->t('%type_name: Delete any Reference entity', $type_params),
    ],
    "view bibcite_reference {$type_id} revisions" => [
      'title' => $this
        ->t('%type_name: View revisions', $type_params),
      'description' => t('To view a revision, you also need permission to view the reference item.'),
    ],
    "revert bibcite_reference {$type_id} revisions" => [
      'title' => $this
        ->t('%type_name: Revert revisions', $type_params),
      'description' => t('To revert a revision, you also need permission to edit the reference item.'),
    ],
    "delete bibcite_reference {$type_id} revisions" => [
      'title' => $this
        ->t('%type_name: Delete revisions', $type_params),
      'description' => $this
        ->t('To delete a revision, you also need permission to delete the reference item.'),
    ],
  ];
}