class EntityPermissions in Entity API 8
Generates entity permissions via their permission providers.
Hierarchy
- class \Drupal\entity\EntityPermissions implements ContainerInjectionInterface
Expanded class hierarchy of EntityPermissions
See also
\Drupal\entity\EntityPermissionProvider
\Drupal\entity\UncacheableEntityPermissionProvider
File
- src/
EntityPermissions.php, line 15
Namespace
Drupal\entityView source
class EntityPermissions implements ContainerInjectionInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new EntityPermissions object.
*
* @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'));
}
/**
* Builds a list of permissions for the participating entity types.
*
* @return array
* The permissions.
*/
public function buildPermissions() {
$permissions = [];
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type) {
if ($entity_type
->hasHandlerClass('permission_provider')) {
$permission_provider_class = $entity_type
->getHandlerClass('permission_provider');
$permission_provider = $this->entityTypeManager
->createHandlerInstance($permission_provider_class, $entity_type);
$permissions += $permission_provider
->buildPermissions($entity_type);
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityPermissions:: |
protected | property | The entity type manager. | |
EntityPermissions:: |
public | function | Builds a list of permissions for the participating entity types. | |
EntityPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
EntityPermissions:: |
public | function | Constructs a new EntityPermissions object. |