You are here

public function ShipmentPermissionProvider::buildPermissions in Commerce Shipping 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

src/ShipmentPermissionProvider.php, line 48

Class

ShipmentPermissionProvider
Provides permissions for shipments.

Namespace

Drupal\commerce_shipping

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) {
    $permissions["manage {$bundle_name} {$entity_type_id}"] = [
      'title' => $this
        ->t('[Shipments] Manage %bundle', [
        '%bundle' => $bundle_info['label'],
      ]),
      'provider' => 'commerce_shipping',
    ];
  }
  return $permissions;
}