class DynamicLocalTasks in Entity Reference Hierarchy 8.2
Same name and namespace in other branches
- 3.x src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\entity_hierarchy\Plugin\Derivative\DynamicLocalTasks
Generates children tab for relevant entities.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\entity_hierarchy\Plugin\Derivative\DynamicLocalTasks implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of DynamicLocalTasks
1 string reference to 'DynamicLocalTasks'
File
- src/
Plugin/ Derivative/ DynamicLocalTasks.php, line 16
Namespace
Drupal\entity_hierarchy\Plugin\DerivativeView source
class DynamicLocalTasks extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The base plugin ID.
*
* @var string
*/
protected $basePluginId;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* Creates the DynamicLocalTasks object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager
* Entity field manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation, EntityFieldManagerInterface $entityFieldManager) {
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
$this->basePluginId = $base_plugin_id;
$this->entityFieldManager = $entityFieldManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'), $container
->get('string_translation'), $container
->get('entity_field.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this->entityFieldManager
->getFieldMapByFieldType('entity_reference_hierarchy') as $entity_type_id => $fields) {
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
if (!$entity_type
->hasLinkTemplate('canonical') || isset($this->derivatives["{$entity_type_id}.entity_hierarchy_reorder"])) {
continue;
}
$this->derivatives["{$entity_type_id}.entity_hierarchy_reorder"] = [
'route_name' => "entity.{$entity_type_id}.entity_hierarchy_reorder",
'title' => $this
->t('Children'),
'base_route' => "entity.{$entity_type_id}.canonical",
'weight' => 30,
] + $base_plugin_definition;
}
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:: |
|
DynamicLocalTasks:: |
protected | property | The base plugin ID. | |
DynamicLocalTasks:: |
protected | property | Entity field manager. | |
DynamicLocalTasks:: |
protected | property | The entity type manager. | |
DynamicLocalTasks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
DynamicLocalTasks:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DynamicLocalTasks:: |
public | function | Creates the DynamicLocalTasks object. | |
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. |