function content_translation_views_data_alter

content_translation_views_data_alter(array &$data)

Implements hook_views_data_alter().

File

core/modules/content_translation/content_translation.module, line 241
Allows entities to be translated into different languages.

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::entityManager()->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',
        ],
      ];
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!content_translation!content_translation.module/function/content_translation_views_data_alter/8.1.x