function ConfigTranslationHooks::entityOperation
Implements hook_entity_operation().
File
-
core/
modules/ config_translation/ src/ Hook/ ConfigTranslationHooks.php, line 178
Class
- ConfigTranslationHooks
- Hook implementations for config_translation.
Namespace
Drupal\config_translation\HookCode
public function entityOperation(EntityInterface $entity) {
$operations = [];
$entity_type = $entity->getEntityType();
if ($entity_type->entityClassImplements(ConfigEntityInterface::class) && $entity->hasLinkTemplate('config-translation-overview') && \Drupal::currentUser()->hasPermission('translate configuration')) {
$link_template = 'config-translation-overview';
if ($entity instanceof FieldConfigInterface) {
$link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}";
}
$operations['translate'] = [
'title' => t('Translate'),
'weight' => 50,
'url' => $entity->toUrl($link_template),
];
}
return $operations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.