function entity_clone_entity_operation in Entity Clone 8
Declares entity operations.
Parameters
\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().
See also
\Drupal\Core\Entity\EntityListBuilderInterface::getOperations()
File
- ./
entity_clone.module, line 123 - Contains entity_clone.module.
Code
function entity_clone_entity_operation(EntityInterface $entity) {
if ($entity
->hasLinkTemplate('clone-form') && $entity
->access('clone')) {
return [
'clone' => [
'title' => t('Clone'),
'weight' => 50,
'url' => $entity
->toUrl('clone-form')
->mergeOptions([
'query' => \Drupal::destination()
->getAsArray(),
]),
],
];
}
return [];
}