Same name and namespace in other branches
  1. 8.x-1.x entity_clone.module \entity_clone_entity_operation() 1 commentaire

Declares entity operations.

Paramètres

\Drupal\Core\Entity\EntityInterface $entity: The entity on which the linked operations will be performed.

Return value

array An operations array as returned by EntityListBuilderInterface::getOperations().

Voir aussi

\Drupal\Core\Entity\EntityListBuilderInterface::getOperations()

Fichier

./entity_clone.module, line 124

Code

function entity_clone_entity_operation(EntityInterface $entity) {
    if ($entity->hasLinkTemplate('clone-form') && $entity->access('clone') && !$entity->isNew()) {
        return [
            'clone' => [
                'title' => t('Clone'),
                'weight' => 50,
                'url' => $entity->toUrl('clone-form')
                    ->mergeOptions([
                    'query' => \Drupal::destination()->getAsArray(),
                ]),
            ],
        ];
    }
    return [];
}