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

3 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().
entity_test_operation_entity_operation in core/modules/system/tests/modules/entity_test_operation/entity_test_operation.module
Implements hook_entity_operation().
menu_operations_link_test_entity_operation in core/modules/menu_link_content/tests/menu_operations_link_test/menu_operations_link_test.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 2112

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.