function content_translation_views_data_alter
Same name in other branches
- 9 core/modules/content_translation/content_translation.module \content_translation_views_data_alter()
- 10 core/modules/content_translation/content_translation.module \content_translation_views_data_alter()
- 11.x core/modules/content_translation/content_translation.module \content_translation_views_data_alter()
Implements hook_views_data_alter().
File
-
core/
modules/ content_translation/ content_translation.module, line 335
Code
function content_translation_views_data_alter(array &$data) {
// Add the content translation entity link definition to Views data for entity
// types having translation enabled.
$entity_types = \Drupal::entityTypeManager()->getDefinitions();
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
$manager = \Drupal::service('content_translation.manager');
foreach ($entity_types as $entity_type_id => $entity_type) {
$base_table = $entity_type->getBaseTable();
if (isset($data[$base_table]) && $entity_type->hasLinkTemplate('drupal:content-translation-overview') && $manager->isEnabled($entity_type_id)) {
$t_arguments = [
'@entity_type_label' => $entity_type->getLabel(),
];
$data[$base_table]['translation_link'] = [
'field' => [
'title' => t('Link to translate @entity_type_label', $t_arguments),
'help' => t('Provide a translation link to the @entity_type_label.', $t_arguments),
'id' => 'content_translation_link',
],
];
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.