function ContentTranslationHooks::entityOperation

Implements hook_entity_operation().

File

core/modules/content_translation/src/Hook/ContentTranslationHooks.php, line 294

Class

ContentTranslationHooks
Hook implementations for content_translation.

Namespace

Drupal\content_translation\Hook

Code

public function entityOperation(EntityInterface $entity) {
    $operations = [];
    if ($entity->hasLinkTemplate('drupal:content-translation-overview') && content_translation_translate_access($entity)->isAllowed()) {
        $operations['translate'] = [
            'title' => t('Translate'),
            'url' => $entity->toUrl('drupal:content-translation-overview'),
            'weight' => 50,
        ];
    }
    return $operations;
}

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