function hook_entity_operation

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

15 functions implement hook_entity_operation()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

BlockContentHooks::entityOperation in core/modules/block_content/src/Hook/BlockContentHooks.php
Implements hook_entity_operation().
ConfigTranslationHooks::entityOperation in core/modules/config_translation/src/Hook/ConfigTranslationHooks.php
Implements hook_entity_operation().
config_translation_entity_operation in core/modules/config_translation/config_translation.module
Implements hook_entity_operation().
ContentTranslationHooks::entityOperation in core/modules/content_translation/src/Hook/ContentTranslationHooks.php
Implements hook_entity_operation().
content_translation_entity_operation in core/modules/content_translation/content_translation.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 2092

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.