You are here

function entity_entity_operation in Entity API 8

Implements hook_entity_operation().

File

./entity.module, line 26
Provides expanded entity APIs.

Code

function entity_entity_operation(EntityInterface $entity) {
  $operations = [];
  $entity_type = $entity
    ->getEntityType();
  if ($entity_type
    ->hasLinkTemplate('duplicate-form') && $entity
    ->access('duplicate')) {
    $operations['duplicate'] = [
      'title' => t('Duplicate'),
      'weight' => 40,
      'url' => $entity
        ->toUrl('duplicate-form'),
    ];
  }
  return $operations;
}