class CommerceAutoSkuPermissionController in Commerce AutoSKU 8.2
Provides dynamic permissions of the commerce_autosku module.
Hierarchy
- class \Drupal\commerce_autosku\CommerceAutoSkuPermissionController implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of CommerceAutoSkuPermissionController
File
- src/
CommerceAutoSkuPermissionController.php, line 19 - Contains \Drupal\commerce_autosku\AutoEntityLabelPermissionController.
Namespace
Drupal\commerce_autoskuView source
class CommerceAutoSkuPermissionController implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
/**
* Constructs a new AutoEntityLabelPermissionController instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Returns an array of commerce_autosku permissions
*
* @return array
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommerceAutoSkuPermissionController:: |
protected | property | The entity manager. | |
CommerceAutoSkuPermissionController:: |
public | function | Returns an array of commerce_autosku permissions | |
CommerceAutoSkuPermissionController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
CommerceAutoSkuPermissionController:: |
public | function | Constructs a new AutoEntityLabelPermissionController instance. | |
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. |