class MetatagPermissions in Metatag 8
Provides dynamic permissions for the Metatag module.
Hierarchy
- class \Drupal\metatag_extended_perms\MetatagPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of MetatagPermissions
See also
metatag_extended_perms.permissions.yml
File
- metatag_extended_perms/
src/ MetatagPermissions.php, line 16
Namespace
Drupal\metatag_extended_permsView source
class MetatagPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The Metatag Tag Plugin Manager.
*
* @var \Drupal\metatag\MetatagTagPluginManager
*/
protected $tagManager;
/**
* The Metatag Group Plugin Manager.
*
* @var \Drupal\metatag\MetatagGroupPluginManager
*/
protected $groupManager;
/**
* Constructs a MetatagPermissions instance.
*
* @param \Drupal\metatag\MetatagTagPluginManager $tag_manager
* The tag plugin manager.
* @param \Drupal\metatag\MetatagGroupPluginManager $group_manager
* The group plugin manager.
*/
public function __construct(MetatagTagPluginManager $tag_manager, MetatagGroupPluginManager $group_manager) {
$this->tagManager = $tag_manager;
$this->groupManager = $group_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.metatag.tag'), $container
->get('plugin.manager.metatag.group'));
}
/**
* Get each permission.
*
* @return array
* Permissions array.
*/
public function permissions() {
$permissions = [];
// Build permissions for each tag in each group.
foreach ($this->tagManager
->getDefinitions() as $key => $metatag) {
$group = $this->groupManager
->getDefinition($metatag['group']);
$permissions += [
'access metatag ' . $metatag['group'] . '__' . $key => [
'title' => $this
->t('Access %tag in %group', [
'%tag' => $metatag['label'],
'%group' => $group['label'],
]),
],
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MetatagPermissions:: |
protected | property | The Metatag Group Plugin Manager. | |
MetatagPermissions:: |
protected | property | The Metatag Tag Plugin Manager. | |
MetatagPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
MetatagPermissions:: |
public | function | Get each permission. | |
MetatagPermissions:: |
public | function | Constructs a MetatagPermissions 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. |