You are here

public function EntityPermissions::buildPermissions in Entity API 8

Builds a list of permissions for the participating entity types.

Return value

array The permissions.

1 string reference to 'EntityPermissions::buildPermissions'
entity.permissions.yml in ./entity.permissions.yml
entity.permissions.yml

File

src/EntityPermissions.php, line 49

Class

EntityPermissions
Generates entity permissions via their permission providers.

Namespace

Drupal\entity

Code

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

  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type) {
    if ($entity_type
      ->hasHandlerClass('permission_provider')) {
      $permission_provider_class = $entity_type
        ->getHandlerClass('permission_provider');
      $permission_provider = $this->entityTypeManager
        ->createHandlerInstance($permission_provider_class, $entity_type);
      $permissions += $permission_provider
        ->buildPermissions($entity_type);
    }
  }
  return $permissions;
}