function hook_entity_operation

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_operation()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_operation()
  3. 11.x 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

10 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.

block_content_entity_operation in core/modules/block_content/block_content.module
Implements hook_entity_operation().
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().

... See full list

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 2109

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.