You are here

public function EntityLegalPermissions::permissions in Entity Legal 8.2

Same name and namespace in other branches
  1. 4.0.x src/EntityLegalPermissions.php \Drupal\entity_legal\EntityLegalPermissions::permissions()
  2. 3.0.x src/EntityLegalPermissions.php \Drupal\entity_legal\EntityLegalPermissions::permissions()

Returns an array of entity legal document permissions.

Return value

array The entity legal document permissions.

See also

\Drupal\user\PermissionHandlerInterface::getPermissions()

1 string reference to 'EntityLegalPermissions::permissions'
entity_legal.permissions.yml in ./entity_legal.permissions.yml
entity_legal.permissions.yml

File

src/EntityLegalPermissions.php, line 23

Class

EntityLegalPermissions
Provides dynamic permissions for nodes of different types.

Namespace

Drupal\entity_legal

Code

public function permissions() {
  $perms = [];

  /** @var \Drupal\entity_legal\Entity\EntityLegalDocument $document */
  foreach (EntityLegalDocument::loadMultiple() as $document) {
    $perms[$document
      ->getPermissionView()] = [
      'title' => $this
        ->t('View "@name"', [
        '@name' => $document
          ->id(),
      ]),
      'description' => $this
        ->t('Allow users to view the legal document.'),
    ];
    $perms[$document
      ->getPermissionExistingUser()] = [
      'title' => $this
        ->t('Re-accept "@name"', [
        '@name' => $document
          ->id(),
      ]),
      'description' => $this
        ->t('Existing user roles that must re-accept the legal document.'),
    ];
  }
  return $perms;
}