class BetterFormatsPermissions in Better Formats 8
Provides dynamic permissions of the better formats module.
Hierarchy
- class \Drupal\better_formats\BetterFormatsPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of BetterFormatsPermissions
File
- src/
BetterFormatsPermissions.php, line 13
Namespace
Drupal\better_formatsView source
class BetterFormatsPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new BetterFormatsPermissions instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Returns an array of better formats permissions.
*
* @return array
*/
public function permissions() {
$permissions = [];
// Generate permissions for each entity type.
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->get('field_ui_base_route')) {
$permissions['hide format selection for ' . $entity_type_id] = [
'title' => $this
->t('Hide format selection for @label', [
'@label' => $entity_type
->getLabel(),
]),
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BetterFormatsPermissions:: |
protected | property | The entity manager. | |
BetterFormatsPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
BetterFormatsPermissions:: |
public | function | Returns an array of better formats permissions. | |
BetterFormatsPermissions:: |
public | function | Constructs a new BetterFormatsPermissions 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. |