I'm trying to add a custom entity operation to taxonomy terms of a specific vocabulary.
I've found documentation on using hook_entity_operation() to add the operation, and that works, but I'm not sure what to do from there.
Here's the hook implementation:
function nm_target_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
$operations = [];
if ($entity->getEntityTypeId() == 'taxonomy_term' && $entity->vid->getString() == 'data-source') {
$operations['import'] = [
'title' => t('Re-import'),
'url' => // what goes here?
'weight' => 50,
];
}
return $operations;
}
If I want to have a confirmation page at /taxonomy/term/{taxonomy_term}/import, what do I put in the URL property and what kind of class should that route point at?
I took a look at Entity Clone module as that's the only contribute module we use that implements that hook, but that does complicated things with link templates that I don't understand.