public function PaymentMethodPermissionProvider::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 EntityPermissionProviderBase::buildPermissions
File
- modules/payment/ src/ PaymentMethodPermissionProvider.php, line 19 
Class
- PaymentMethodPermissionProvider
- Provides permissions for payment methods.
Namespace
Drupal\commerce_paymentCode
public function buildPermissions(EntityTypeInterface $entity_type) {
  $entity_type_id = $entity_type
    ->id();
  $plural_label = $entity_type
    ->getPluralLabel();
  $admin_permission = $entity_type
    ->getAdminPermission() ?: "administer {$entity_type_id}";
  $permissions[$admin_permission] = [
    'title' => $this
      ->t('Administer @type', [
      '@type' => $plural_label,
    ]),
    'restrict access' => TRUE,
  ];
  $permissions["view any {$entity_type_id}"] = [
    'title' => $this
      ->t('View any payment method'),
    'restrict access' => TRUE,
  ];
  $permissions["update any {$entity_type_id}"] = [
    'title' => $this
      ->t('Update any payment method'),
    'restrict access' => TRUE,
  ];
  $permissions["delete any {$entity_type_id}"] = [
    'title' => $this
      ->t('Delete any payment method'),
    'restrict access' => TRUE,
  ];
  $permissions["manage own {$entity_type_id}"] = [
    'title' => $this
      ->t('Manage own @type', [
      '@type' => $plural_label,
    ]),
  ];
  return $this
    ->processPermissions($permissions, $entity_type);
}