diff --git a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php index dc44bca..654520d 100644 --- a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php +++ b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php @@ -33,3 +33,5 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { return $text; } } + +} diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index fa1cf3e..9cbb31c 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -267,6 +267,15 @@ protected function addEntityLinks(array &$data) { ], ]; } + if ($this->entityType->hasLinkTemplate('drupal:content-translation-overview')) { + $data['translate_' . $entity_type_id] = [ + 'field' => [ + 'title' => $this->t('Link to translate @entity_type_label', $t_arguments), + 'help' => $this->t('Provide a translate link to the @entity_type_label.', $t_arguments), + 'id' => 'content_translation_link', + ], + ]; + } } /** diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php index fb34794..e8e49d6 100644 --- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php @@ -718,11 +718,13 @@ public function testEntityLinks() { $this->baseEntityType->setLinkTemplate('canonical', '/entity_test/{entity_test}'); $this->baseEntityType->setLinkTemplate('edit-form', '/entity_test/{entity_test}/edit'); $this->baseEntityType->setLinkTemplate('delete-form', '/entity_test/{entity_test}/delete'); + $this->baseEntityType->setLinkTemplate('drupal:content-translation-overview', '/entity_test/{entity_test}/translate'); $data = $this->viewsData->getViewsData(); $this->assertEquals('entity_link', $data['entity_test']['view_entity_test']['field']['id']); $this->assertEquals('entity_link_edit', $data['entity_test']['edit_entity_test']['field']['id']); $this->assertEquals('entity_link_delete', $data['entity_test']['delete_entity_test']['field']['id']); + $this->assertEquals('content_translation_link', $data['entity_test']['translate_entity_test']['field']['id']); } /**