diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 20d72ed..f978a1a 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -11,6 +11,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\TranslatableInterface; +use Drupal\node\NodeInterface; /** * Implements hook_help(). @@ -127,6 +128,21 @@ function content_translation_entity_bundle_info_alter(&$bundles) { } /** + * Implements hook_entity_operation_alter(). + */ +function content_translation_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) { + // @todo Use an access permission. + if ($entity instanceof NodeInterface && $entity->isTranslatable()) { + $uri = $entity->uri(); + $operations['translate'] = array( + 'title' => $this->t('Translate'), + 'href' => $uri['path'] . '/translations', + 'options' => $uri['options'], + ); + } +} + +/** * Implements hook_menu(). */ function content_translation_menu() { diff --git a/core/modules/node/lib/Drupal/node/NodeListController.php b/core/modules/node/lib/Drupal/node/NodeListController.php index f5cd26b..92b5fc1 100644 --- a/core/modules/node/lib/Drupal/node/NodeListController.php +++ b/core/modules/node/lib/Drupal/node/NodeListController.php @@ -88,8 +88,7 @@ public function buildHeader() { if (language_multilingual()) { $header['language_name'] = array('data' => $this->t('Language'), 'class' => array(RESPONSIVE_PRIORITY_LOW)); } - $header['operations'] = $this->t('Operations'); - return $header; + return $header + parent::buildHeader(); } /** @@ -120,7 +119,7 @@ public function buildRow(EntityInterface $entity) { $row['language_name'] = language_name($langcode); } $row['operations']['data'] = $this->buildOperations($entity); - return $row; + return $row + parent::buildRow($entity); } /** @@ -128,14 +127,6 @@ public function buildRow(EntityInterface $entity) { */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); - if ($entity->isTranslatable()) { - $uri = $entity->uri(); - $operations['translate'] = array( - 'title' => $this->t('Translate'), - 'href' => $uri['path'] . '/translations', - 'options' => $uri['options'], - ); - } $destination = drupal_get_destination(); foreach ($operations as $key => $operation) {