You are here

public function FieldPermissions::permissions in Voting API Reaction 8

Get implemets permissions invoke in field_permissions.permissions.yml.

Return value

array Add custom permissions.

1 string reference to 'FieldPermissions::permissions'
votingapi_reaction.permissions.yml in ./votingapi_reaction.permissions.yml
votingapi_reaction.permissions.yml

File

src/FieldPermissions.php, line 47

Class

FieldPermissions
Field permissions.

Namespace

Drupal\votingapi_reaction

Code

public function permissions() {
  $map = $this->fieldManager
    ->getFieldMapByFieldType('votingapi_reaction');
  $permissions = [];
  foreach ($map as $entity_type => $info) {
    foreach ($info as $field_name => $field_info) {
      foreach ($field_info['bundles'] as $bundle) {
        $permissions['view reactions on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
          'title' => $this
            ->t('View reactions to field %field in bundle %bundle of entity type %type', [
            '%type' => $entity_type,
            '%bundle' => $bundle,
            '%field' => $field_name,
          ]),
        ];
        $permissions['create reaction on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
          'title' => $this
            ->t('React to field %field in bundle %bundle of entity type %type', [
            '%type' => $entity_type,
            '%bundle' => $bundle,
            '%field' => $field_name,
          ]),
        ];
        $permissions['modify reaction on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
          'title' => $this
            ->t('Modify reaction to field %field in bundle %bundle of entity type %type', [
            '%type' => $entity_type,
            '%bundle' => $bundle,
            '%field' => $field_name,
          ]),
        ];
        $permissions['control reaction status on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
          'title' => $this
            ->t('Conrol reactions status in field %field in bundle %bundle of entity type %type', [
            '%type' => $entity_type,
            '%bundle' => $bundle,
            '%field' => $field_name,
          ]),
        ];
      }
    }
  }
  return $permissions;
}