You are here

protected function TransactionPermissions::buildPermissions in Transaction 8

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

Parameters

\Drupal\transaction\TransactionTypeInterface $type: The transaction type.

Return value

array An associative array of permission names and descriptions.

1 call to TransactionPermissions::buildPermissions()
TransactionPermissions::transactionTypePermissions in src/TransactionPermissions.php
Returns an array of transaction type permissions.

File

src/TransactionPermissions.php, line 71

Class

TransactionPermissions
Provides dynamic permissions for transactions of different types.

Namespace

Drupal\transaction

Code

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