class MaestroEnginePermissions in Maestro 3.x
Same name and namespace in other branches
- 8.2 src/MaestroEnginePermissions.php \Drupal\maestro\MaestroEnginePermissions
Provides dynamic permissions of the maestro module.
Hierarchy
- class \Drupal\maestro\MaestroEnginePermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of MaestroEnginePermissions
File
- src/
MaestroEnginePermissions.php, line 13
Namespace
Drupal\maestroView source
class MaestroEnginePermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Constructs a new MaestroEnginePermissions 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 maestro template permissions.
*
* @return array
* An array of Maestro template permissions.
*/
public function permissions() {
$permissions = [];
$templates = $this->entityManager
->getStorage('maestro_template')
->loadMultiple();
uasort($templates, 'Drupal\\Core\\Config\\Entity\\ConfigEntityBase::sort');
foreach ($templates as $template) {
if ($permission = $template->id) {
$permissions['start template ' . $permission] = [
'title' => $this
->t('Put the @label template into production.', [
'@label' => $template
->label(),
]),
'description' => [
'#prefix' => '<em>',
'#markup' => $this
->t('Only validated templates can be put into production.'),
'#suffix' => '</em>',
],
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MaestroEnginePermissions:: |
protected | property | The entity manager. | |
MaestroEnginePermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
MaestroEnginePermissions:: |
public | function | Returns an array of maestro template permissions. | |
MaestroEnginePermissions:: |
public | function | Constructs a new MaestroEnginePermissions instance. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |