You are here

public function OrderItemPermissionProvider::buildPermissions in Commerce Core 8.2

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

modules/order/src/OrderItemPermissionProvider.php, line 48

Class

OrderItemPermissionProvider
Provides permissions for order items.

Namespace

Drupal\commerce_order

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 order type permissions,
    // to differentiate order types from order item types.
    $permissions["manage {$bundle_name} {$entity_type_id}"] = [
      'title' => $this
        ->t('[Order items] Manage %bundle', [
        '%bundle' => $bundle_info['label'],
      ]),
      'provider' => 'commerce_order',
    ];
  }
  return $permissions;
}