You are here

public function DomainEntityPermissions::permissions in Domain Access Entity 8

Define permissions.

1 string reference to 'DomainEntityPermissions::permissions'
domain_entity.permissions.yml in ./domain_entity.permissions.yml
domain_entity.permissions.yml

File

src/DomainEntityPermissions.php, line 17

Class

DomainEntityPermissions
Dynamic permissions class for Domain Entity.

Namespace

Drupal\domain_entity

Code

public function permissions() {
  $permissions = [];
  $mapper = \Drupal::service('domain_entity.mapper');
  $bundle_info = \Drupal::service('entity_type.bundle.info');
  foreach ($mapper
    ->getEnabledEntityTypes() as $type_id => $entity_type) {
    $bundles = $bundle_info
      ->getBundleInfo($type_id);
    if (!empty($bundles)) {
      foreach ($bundles as $bundle_id => $bundle) {
        $permissions += $this
          ->bundlePermissions($bundle_id, $bundle['label'], $entity_type
          ->id(), $entity_type
          ->getBundleLabel());
      }
    }
  }
  return $permissions;
}