You are here

protected function InvoicePermissions::buildPermissions in Drupal PM (Project Management) 4.x

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

Parameters

\Drupal\pm_invoice\Entity\Invoice $type: The Invoice type.

Return value

array An associative array of permission names and descriptions.

1 call to InvoicePermissions::buildPermissions()
InvoicePermissions::generatePermissions in modules/pm_invoice/src/InvoicePermissions.php
Returns an array of node type permissions.

File

modules/pm_invoice/src/InvoicePermissions.php, line 43

Class

InvoicePermissions
Provides dynamic permissions for Invoice of different types.

Namespace

Drupal\pm_invoice

Code

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