hook_entity_operation

hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity)

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()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1820
Hooks and documentation related to entities.

Code

1
2
3
4
5
6
7
8
9
10
function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
  $operations = array();
  $operations['translate'] = array(
    'title' => t('Translate'),
    'url' => \Drupal\Core\Url::fromRoute('foo_module.entity.translate'),
    'weight' => 50,
  );
 
  return $operations;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.