You are here

class EntityLegalPermissions in Entity Legal 4.0.x

Same name and namespace in other branches
  1. 8.2 src/EntityLegalPermissions.php \Drupal\entity_legal\EntityLegalPermissions
  2. 3.0.x src/EntityLegalPermissions.php \Drupal\entity_legal\EntityLegalPermissions

Provides dynamic permissions for nodes of different types.

Hierarchy

Expanded class hierarchy of EntityLegalPermissions

File

src/EntityLegalPermissions.php, line 11

Namespace

Drupal\entity_legal
View source
class EntityLegalPermissions {
  use StringTranslationTrait;

  /**
   * Returns an array of entity legal document permissions.
   *
   * @return array
   *   The entity legal document permissions.
   *
   * @see \Drupal\user\PermissionHandlerInterface::getPermissions()
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityLegalPermissions::permissions public function Returns an array of entity legal document permissions.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.