class PriceListItemPermissionProvider in Commerce Pricelist 8
Provides permissions for price list items.
Hierarchy
- class \Drupal\commerce_pricelist\PriceListItemPermissionProvider implements EntityHandlerInterface, EntityPermissionProviderInterface uses StringTranslationTrait
Expanded class hierarchy of PriceListItemPermissionProvider
File
- src/
PriceListItemPermissionProvider.php, line 15
Namespace
Drupal\commerce_pricelistView source
class PriceListItemPermissionProvider implements EntityPermissionProviderInterface, EntityHandlerInterface {
use StringTranslationTrait;
/**
* The entity type bundle info.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/**
* Constructs a new PriceListItemPermissionProvider object.
*
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info.
*/
public function __construct(EntityTypeBundleInfoInterface $entity_type_bundle_info) {
$this->entityTypeBundleInfo = $entity_type_bundle_info;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($container
->get('entity_type.bundle.info'));
}
/**
* {@inheritdoc}
*/
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) {
// The title is in a different format than the price list type
// permissions, to differentiate price list types from price list item
// types.
$permissions["manage {$bundle_name} {$entity_type_id}"] = [
'title' => $this
->t('[Pice list items] Manage %bundle', [
'%bundle' => $bundle_info['label'],
]),
'provider' => 'commerce_pricelist',
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PriceListItemPermissionProvider:: |
protected | property | The entity type bundle info. | |
PriceListItemPermissionProvider:: |
public | function |
Builds permissions for the given entity type. Overrides EntityPermissionProviderInterface:: |
|
PriceListItemPermissionProvider:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
PriceListItemPermissionProvider:: |
public | function | Constructs a new PriceListItemPermissionProvider object. | |
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. |