You are here

function hook_entity_operation in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_operation()

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

4 functions implement hook_entity_operation()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

config_translation_entity_operation in core/modules/config_translation/config_translation.module
Implements hook_entity_operation().
content_translation_entity_operation in core/modules/content_translation/content_translation.module
Implements hook_entity_operation().
entity_test_operation_entity_operation in core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module
Implements hook_entity_operation().
field_ui_entity_operation in core/modules/field_ui/field_ui.module
Implements hook_entity_operation().
1 invocation of hook_entity_operation()
EntityListBuilder::getOperations in core/lib/Drupal/Core/Entity/EntityListBuilder.php
Provides an array of information to build a list of operation links.

File

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

Code

function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
  $operations = [];
  $operations['translate'] = [
    'title' => t('Translate'),
    'url' => \Drupal\Core\Url::fromRoute('foo_module.entity.translate'),
    'weight' => 50,
  ];
  return $operations;
}