Commit 5c614800 authored by webchick's avatar webchick

Issue #2325977 by Gábor Hojtsy: Fixed All links lead to same entity...

Issue #2325977 by Gábor Hojtsy: Fixed All links lead to same entity translations in translation overviews.
parent fb557917
......@@ -84,6 +84,9 @@ public function overview(Request $request, $entity_type_id = NULL) {
'source' => $original,
'target' => $language->getId(),
$entity_type_id => $entity->id(),
),
array(
'language' => $language,
)
);
$edit_url = new Url(
......@@ -91,6 +94,9 @@ public function overview(Request $request, $entity_type_id = NULL) {
array(
'language' => $language->getId(),
$entity_type_id => $entity->id(),
),
array(
'language' => $language,
)
);
$delete_url = new Url(
......@@ -98,6 +104,9 @@ public function overview(Request $request, $entity_type_id = NULL) {
array(
'language' => $language->getId(),
$entity_type_id => $entity->id(),
),
array(
'language' => $language,
)
);
$operations = array(
......@@ -114,6 +123,7 @@ public function overview(Request $request, $entity_type_id = NULL) {
$is_original = $langcode == $original;
$label = $entity->getTranslation($langcode)->label();
$link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $entity->getSystemPath());
$link += array('language' => $language);
$row_title = l($label, $link['href'], $link);
if (empty($link['href'])) {
......@@ -126,6 +136,7 @@ public function overview(Request $request, $entity_type_id = NULL) {
if ($entity->access('update')) {
$links['edit'] = array(
'href' => $entity->getSystemPath('edit-form'),
'language' => $language,
);
}
elseif (!$is_original && $handler->getTranslationAccess($entity, 'update')) {
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
/**
......@@ -119,7 +120,13 @@ protected function doTestTranslationOverview() {
foreach ($this->langcodes as $langcode) {
if ($entity->hasTranslation($langcode)) {
$this->assertText($entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation', array('%language' => $langcode)));
$language = new Language(array('id' => $langcode));
$view_path = \Drupal::urlGenerator()->generateFromPath($entity->getSystemPath(), array('language' => $language));
$elements = $this->xpath('//table//a[@href=:href]', array(':href' => $view_path));
$this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', array('%language' => $langcode)));
$edit_path = \Drupal::urlGenerator()->generateFromPath($entity->getSystemPath('edit-form'), array('language' => $language));
$elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(':href' => $edit_path));
$this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', array('%language' => $langcode)));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment