class PaymentMethodPermissionProvider in Commerce Core 8.2
Provides permissions for payment methods.
Hierarchy
- class \Drupal\entity\EntityPermissionProviderBase implements EntityHandlerInterface, EntityPermissionProviderInterface uses StringTranslationTrait
- class \Drupal\commerce_payment\PaymentMethodPermissionProvider uses StringTranslationTrait
Expanded class hierarchy of PaymentMethodPermissionProvider
File
- modules/
payment/ src/ PaymentMethodPermissionProvider.php, line 12
Namespace
Drupal\commerce_paymentView source
class PaymentMethodPermissionProvider extends EntityPermissionProviderBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityPermissionProviderBase:: |
protected | property | The entity type bundle info. | |
EntityPermissionProviderBase:: |
protected | function | Builds permissions for the bundle granularity. | 2 |
EntityPermissionProviderBase:: |
protected | function | Builds permissions for the entity_type granularity. | 2 |
EntityPermissionProviderBase:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
EntityPermissionProviderBase:: |
protected | function | Adds the provider and converts the titles to strings to allow sorting. | |
EntityPermissionProviderBase:: |
public | function | Constructs a new EntityPermissionProvider object. | |
PaymentMethodPermissionProvider:: |
public | function |
Builds permissions for the given entity type. Overrides EntityPermissionProviderBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |