class AutoEntityLabelPermisssionController in Automatic Entity Label 8
Provides dynamic permissions of the auto_entitylabel module.
Hierarchy
- class \Drupal\auto_entitylabel\AutoEntityLabelPermisssionController implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of AutoEntityLabelPermisssionController
File
- src/
AutoEntityLabelPermisssionController.php, line 13
Namespace
Drupal\auto_entitylabelView source
class AutoEntityLabelPermisssionController implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Constructs a new AutoEntityLabelPermisssionController instance.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity.manager'));
}
/**
* Returns an array of auto_entitylabel permissions.
*
* @return array
* Return array with permission.
*/
public function autoEntityLabelPermissions() {
$permissions = [];
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
// Create a permission for each fieldable entity to manage
// the entity labels.
$permissions['administer ' . $entity_type_id . ' labels'] = [
'title' => $this
->t('%entity_label: Administer Entity Labels', [
'%entity_label' => $entity_type
->getLabel(),
]),
'restrict access' => TRUE,
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AutoEntityLabelPermisssionController:: |
protected | property | The entity manager. | |
AutoEntityLabelPermisssionController:: |
public | function | Returns an array of auto_entitylabel permissions. | |
AutoEntityLabelPermisssionController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
AutoEntityLabelPermisssionController:: |
public | function | Constructs a new AutoEntityLabelPermisssionController 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. |