You are here

public function WishlistItemPermissionProvider::buildPermissions in Commerce Wishlist 8.3

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/WishlistItemPermissionProvider.php, line 48

Class

WishlistItemPermissionProvider
Provides permissions for wishlist items.

Namespace

Drupal\commerce_wishlist

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('[Wishlist items] Manage %bundle', [
        '%bundle' => $bundle_info['label'],
      ]),
      'provider' => 'commerce_wishlist',
    ];
  }
  return $permissions;
}