class FieldPermissions in Voting API Reaction 8
Field permissions.
Hierarchy
- class \Drupal\votingapi_reaction\FieldPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of FieldPermissions
File
- src/
FieldPermissions.php, line 13
Namespace
Drupal\votingapi_reactionView source
class FieldPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* Entity field manager service.
*
* @var \Drupal\Core\Entity\EntityFieldManager
*/
protected $fieldManager;
/**
* Constructs a FieldPermissionsService instance.
*
* @param \Drupal\Core\Entity\EntityFieldManager $fieldManager
* Entity field manager service.
*/
public function __construct(EntityFieldManager $fieldManager) {
$this->fieldManager = $fieldManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_field.manager'));
}
/**
* Get implemets permissions invoke in field_permissions.permissions.yml.
*
* @return array
* Add custom permissions.
*/
public function permissions() {
$map = $this->fieldManager
->getFieldMapByFieldType('votingapi_reaction');
$permissions = [];
foreach ($map as $entity_type => $info) {
foreach ($info as $field_name => $field_info) {
foreach ($field_info['bundles'] as $bundle) {
$permissions['view reactions on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
'title' => $this
->t('View reactions to field %field in bundle %bundle of entity type %type', [
'%type' => $entity_type,
'%bundle' => $bundle,
'%field' => $field_name,
]),
];
$permissions['create reaction on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
'title' => $this
->t('React to field %field in bundle %bundle of entity type %type', [
'%type' => $entity_type,
'%bundle' => $bundle,
'%field' => $field_name,
]),
];
$permissions['modify reaction on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
'title' => $this
->t('Modify reaction to field %field in bundle %bundle of entity type %type', [
'%type' => $entity_type,
'%bundle' => $bundle,
'%field' => $field_name,
]),
];
$permissions['control reaction status on ' . $entity_type . ':' . $bundle . ':' . $field_name] = [
'title' => $this
->t('Conrol reactions status in field %field in bundle %bundle of entity type %type', [
'%type' => $entity_type,
'%bundle' => $bundle,
'%field' => $field_name,
]),
];
}
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldPermissions:: |
protected | property | Entity field manager service. | |
FieldPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
FieldPermissions:: |
public | function | Get implemets permissions invoke in field_permissions.permissions.yml. | |
FieldPermissions:: |
public | function | Constructs a FieldPermissionsService 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. |