class ExtrasPermissions in Display Suite 8.4
Same name and namespace in other branches
- 8.2 modules/ds_extras/src/ExtrasPermissions.php \Drupal\ds_extras\ExtrasPermissions
- 8.3 modules/ds_extras/src/ExtrasPermissions.php \Drupal\ds_extras\ExtrasPermissions
Provides dynamic permissions of the ds extras module.
Hierarchy
- class \Drupal\ds_extras\ExtrasPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of ExtrasPermissions
File
- modules/
ds_extras/ src/ ExtrasPermissions.php, line 14
Namespace
Drupal\ds_extrasView source
class ExtrasPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new FieldUiPermissions instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type 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 ds extras permissions.
*/
public function extrasPermissions() {
$permissions = [];
if (\Drupal::config('ds_extras.settings')
->get('field_permissions')) {
$entities = $this->entityTypeManager
->getDefinitions();
foreach ($entities as $entity_type => $info) {
// @todo do this on all fields ?
// @todo hide switch field if enabled
$fields = Ds::getFields($entity_type);
foreach ($fields as $key => $finfo) {
$permissions['view ' . $key . ' on ' . $entity_type] = [
'title' => $this
->t('View @field on @entity_type', [
'@field' => $finfo['title'],
'@entity_type' => $info
->getLabel(),
]),
];
}
}
}
return $permissions;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExtrasPermissions:: |
protected | property | The entity manager. | |
ExtrasPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ExtrasPermissions:: |
public | function | Returns an array of ds extras permissions. | |
ExtrasPermissions:: |
public | function | Constructs a new FieldUiPermissions 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. |