Skip to content
Snippets Groups Projects
Verified Commit 9f35abc0 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2567745 by mohit_aghera, smustgrave, quietone, andypost, dww, alexpott:...

Issue #2567745 by mohit_aghera, smustgrave, quietone, andypost, dww, alexpott: \Drupal\taxonomy\Plugin\views\field\TermName::getItems should work with links

(cherry picked from commit e3f208ee)
parent 5b91abc9
No related branches found
No related tags found
5 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment
......@@ -23,9 +23,10 @@ public function getItems(ResultRow $values) {
if ($this->options['convert_spaces']) {
foreach ($items as &$item) {
// Replace spaces with hyphens.
$name = $item['raw']->get('value')->getValue();
// @todo Add link support https://www.drupal.org/node/2567745
$item['rendered']['#context']['value'] = str_replace(' ', '-', $name);
$name = str_replace(' ', '-', $item['raw']->get('value')->getValue());
empty($this->options['settings']['link_to_entity']) ?
$item['rendered']['#context']['value'] = $name :
$item['rendered']['#title']['#context']['value'] = $name;
}
}
return $items;
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\taxonomy\Functional\Views;
use Drupal\Core\Link;
use Drupal\views\Views;
/**
......@@ -48,6 +49,19 @@ public function testTermNameField() {
$this->assertEquals(str_replace(' ', '-', $this->term1->getName()), $view->getStyle()->getField(0, 'name'));
$this->assertEquals($this->term2->getName(), $view->getStyle()->getField(1, 'name'));
// Enable link_to_entity option and ensure that title is displayed properly.
$view = Views::getView('test_taxonomy_term_name');
$display =& $view->storage->getDisplay('default');
$display['display_options']['fields']['name']['convert_spaces'] = TRUE;
$display['display_options']['fields']['name']['settings']['link_to_entity'] = TRUE;
$view->storage->invalidateCaches();
$this->executeView($view);
$expected_link1 = Link::fromTextAndUrl(str_replace(' ', '-', $this->term1->getName()), $this->term1->toUrl());
$expected_link2 = Link::fromTextAndUrl($this->term2->getName(), $this->term2->toUrl());
$this->assertEquals($expected_link1->toString(), $view->getStyle()->getField(0, 'name'));
$this->assertEquals($expected_link2->toString(), $view->getStyle()->getField(1, 'name'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment