class EntityTasksDeriver in Entity API 8
Derives local tasks for entity types.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\entity\Plugin\Derivative\EntityTasksDeriver implements ContainerDeriverInterface
Expanded class hierarchy of EntityTasksDeriver
1 string reference to 'EntityTasksDeriver'
File
- src/
Plugin/ Derivative/ EntityTasksDeriver.php, line 13
Namespace
Drupal\entity\Plugin\DerivativeView source
class EntityTasksDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs an entity local tasks deriver.
*
* @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, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if (!$this->derivatives) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
$handlers = $entity_type
->getHandlerClasses();
if (isset($handlers['local_task_provider'])) {
foreach ($handlers['local_task_provider'] as $class) {
/** @var \Drupal\entity\Menu\EntityLocalTaskProviderInterface $handler */
$handler = $this->entityTypeManager
->createHandlerInstance($class, $entity_type);
$this->derivatives += $handler
->buildLocalTasks($entity_type);
}
}
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityTasksDeriver:: |
protected | property | The entity type manager. | |
EntityTasksDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityTasksDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityTasksDeriver:: |
public | function | Constructs an entity local tasks deriver. |