You are here

class NodeViewPermissionsPermissions in Node View Permissions 8

Class definition.

@category NodeViewPermissionsPermissions

@package Access Control

Hierarchy

Expanded class hierarchy of NodeViewPermissionsPermissions

File

src/NodeViewPermissionsPermissions.php, line 15

Namespace

Drupal\node_view_permissions
View source
class NodeViewPermissionsPermissions {
  use StringTranslationTrait;

  /**
   * Permission function.
   *
   * Added the permissions.
   */
  public function permissions() {
    $permissions = [];
    $nodeTypes = NodeType::loadMultiple();
    foreach ($nodeTypes as $nodeType) {

      /** @var \Drupal\node\Entity\NodeType $nodeType */
      $permission = 'view any ' . $nodeType
        ->id() . ' content';
      $permissions[$permission] = [
        'title' => $this
          ->t('<em>@type_label</em>: View any content', [
          '@type_label' => $nodeType
            ->label(),
        ]),
      ];
      $permission = 'view own ' . $nodeType
        ->id() . ' content';
      $permissions[$permission] = [
        'title' => $this
          ->t('<em>@type_label</em>: View own content', [
          '@type_label' => $nodeType
            ->label(),
        ]),
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NodeViewPermissionsPermissions::permissions public function Permission function.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.