class DynamicLocalTasks in Entity Clone 8
Defines dynamic local tasks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\entity_clone\Plugin\Derivative\DynamicLocalTasks implements ContainerDeriverInterface
Expanded class hierarchy of DynamicLocalTasks
1 string reference to 'DynamicLocalTasks'
File
- src/
Plugin/ Derivative/ DynamicLocalTasks.php, line 14
Namespace
Drupal\entity_clone\Plugin\DerivativeView source
class DynamicLocalTasks extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The translation manager.
*
* @var \Drupal\Core\StringTranslation\TranslationManager
*/
protected $translationManager;
/**
* Constructs a new DynamicLocalTasks.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StringTranslation\TranslationManager $string_translation
* The translation manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationManager $string_translation) {
$this->entityTypeManager = $entity_type_manager;
$this->translationManager = $string_translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'), $container
->get('string_translation'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
$has_clone_path = $entity_type
->hasLinkTemplate('clone-form');
$has_canonical_path = $entity_type
->hasLinkTemplate('canonical');
if ($has_clone_path) {
$this->derivatives["{$entity_type_id}.clone_tab"] = [
'route_name' => "entity.{$entity_type_id}.clone_form",
'title' => $this->translationManager
->translate('Clone'),
'base_route' => "entity.{$entity_type_id}." . ($has_canonical_path ? "canonical" : "edit_form"),
'weight' => 100,
];
}
}
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 entity type manager. | |
DynamicLocalTasks:: |
protected | property | The translation 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 | Constructs a new DynamicLocalTasks. |