You are here

public function LikeDislikePermissions::buildPermissions in Like & Dislike 8

Builds a list of like_and_dislike related permissions.

Return value

array An associative array of permission names and descriptions.

1 string reference to 'LikeDislikePermissions::buildPermissions'
like_and_dislike.permissions.yml in ./like_and_dislike.permissions.yml
like_and_dislike.permissions.yml

File

src/LikeDislikePermissions.php, line 74

Class

LikeDislikePermissions
Provides dynamic permissions for nodes of different types.

Namespace

Drupal\like_and_dislike

Code

public function buildPermissions() {
  $permissions = [];
  $enabled_entity_types = $this->configFactory
    ->get('like_and_dislike.settings')
    ->get('enabled_types');
  $vote_types = VoteType::loadMultiple();
  foreach ($enabled_entity_types as $entity_type_id => $bundles) {

    // The entity type has no bundles. Add entity type permission only.
    $this
      ->addLikeAndDislikePermission($permissions, $vote_types, $entity_type_id, $bundles);
  }
  return $permissions;
}