Same name in other branches
  1. 8.x-1.x src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\entity_clone\Plugin\Derivative\DynamicLocalTasks::getDerivativeDefinitions()

Fichier

src/Plugin/Derivative/DynamicLocalTasks.php, line 56

Classe

DynamicLocalTasks
Defines dynamic local tasks.

Namespace

Drupal\entity_clone\Plugin\Derivative

Code

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;
}