function EntityTestHooks::entityOperation
Implements hook_entity_operation().
Attributes
#[Hook('entity_operation')]
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php, line 393
Class
- EntityTestHooks
- Hook implementations for entity_test.
Namespace
Drupal\entity_test\HookCode
public function entityOperation(EntityInterface $entity, CacheableMetadata $cacheability) : array {
if (!$entity instanceof EntityTest) {
return [];
}
$cacheability->addCacheTags([
'entity_test_operation_tag_test',
]);
$operations['entity_test_custom_operation'] = [
'title' => 'Custom Home',
'weight' => 20,
'url' => Url::fromRoute('<front>'),
];
return $operations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.