You are here

public function CommerceAutoSkuPermissionController::autoSkuPermissions in Commerce AutoSKU 8.2

Returns an array of commerce_autosku permissions

Return value

array

1 string reference to 'CommerceAutoSkuPermissionController::autoSkuPermissions'
commerce_autosku.permissions.yml in ./commerce_autosku.permissions.yml
commerce_autosku.permissions.yml

File

src/CommerceAutoSkuPermissionController.php, line 52
Contains \Drupal\commerce_autosku\AutoEntityLabelPermissionController.

Class

CommerceAutoSkuPermissionController
Provides dynamic permissions of the commerce_autosku module.

Namespace

Drupal\commerce_autosku

Code

public function autoSkuPermissions() {
  $permissions = [];
  foreach ($this->entityManager
    ->getDefinitions() as $entity_type_id => $entity_type) {

    // Create a permission for each entity type to manage the entity
    // labels.
    if ($entity_type
      ->hasLinkTemplate('auto-sku') && $entity_type
      ->hasKey('label')) {
      $permissions['administer ' . $entity_type_id . ' SKU'] = [
        'title' => $this
          ->t('%entity_label: Administer automatic SKU', [
          '%entity_label' => $entity_type
            ->getLabel(),
        ]),
        'restrict access' => TRUE,
      ];
    }
  }
  return $permissions;
}