FieldUiPermissions.php in Drupal 8
File
core/modules/field_ui/src/FieldUiPermissions.php
View source
<?php
namespace Drupal\field_ui;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FieldUiPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
use DeprecatedServicePropertyTrait;
protected $deprecatedProperties = [
'entityManager' => 'entity.manager',
];
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
public function fieldPermissions() {
$permissions = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->get('field_ui_base_route')) {
$permissions['administer ' . $entity_type_id . ' fields'] = [
'title' => $this
->t('%entity_label: Administer fields', [
'%entity_label' => $entity_type
->getLabel(),
]),
'restrict access' => TRUE,
];
$permissions['administer ' . $entity_type_id . ' form display'] = [
'title' => $this
->t('%entity_label: Administer form display', [
'%entity_label' => $entity_type
->getLabel(),
]),
];
$permissions['administer ' . $entity_type_id . ' display'] = [
'title' => $this
->t('%entity_label: Administer display', [
'%entity_label' => $entity_type
->getLabel(),
]),
];
}
}
return $permissions;
}
}