You are here

public function PriceListItemPermissionProvider::buildPermissions in Commerce Pricelist 8

Builds permissions for the given entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

Return value

array The permissions.

Overrides EntityPermissionProviderInterface::buildPermissions

File

src/PriceListItemPermissionProvider.php, line 48

Class

PriceListItemPermissionProvider
Provides permissions for price list items.

Namespace

Drupal\commerce_pricelist

Code

public function buildPermissions(EntityTypeInterface $entity_type) {
  $entity_type_id = $entity_type
    ->id();
  $bundles = $this->entityTypeBundleInfo
    ->getBundleInfo($entity_type_id);
  $permissions = [];
  foreach ($bundles as $bundle_name => $bundle_info) {

    // The title is in a different format than the price list type
    // permissions, to differentiate price list types from price list item
    // types.
    $permissions["manage {$bundle_name} {$entity_type_id}"] = [
      'title' => $this
        ->t('[Pice list items] Manage %bundle', [
        '%bundle' => $bundle_info['label'],
      ]),
      'provider' => 'commerce_pricelist',
    ];
  }
  return $permissions;
}