Same name in other branches
- 8.x-1.x src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\entity_clone\Plugin\Derivative\DynamicLocalTasks
Defines dynamic local tasks.
Hierarchy
- class \Drupal\entity_clone\Plugin\Derivative\DynamicLocalTasks extends \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Core\Plugin\Discovery\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
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
DynamicLocalTasks::$entityTypeManager | protected | property | The entity type manager. |
DynamicLocalTasks::$translationManager | protected | property | The translation manager. |
DynamicLocalTasks::create | public static | function | |
DynamicLocalTasks::getDerivativeDefinitions | public | function | |
DynamicLocalTasks::__construct | public | function | Constructs a new DynamicLocalTasks. |