Skip to content
Snippets Groups Projects
Verified Commit e46f1e26 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 8ec568f2
No related branches found
No related tags found
9 merge requests!8394[warning] array_flip(): Can only flip STRING and INTEGER values, when saving a non-revisionable custom content entity,!7780issue 3443822: fix for 'No route found for the specified format html. Supported formats: json, xml.',!5013Issue #3071143: Table Render Array Example Is Incorrect,!4848Issue #1566662: Update module should send notifications on Thursdays,!4792Issue #2230689: Remove redundant "Italic" style,!4220Issue #3368223: Link field > Access to internal links is not checked on display.,!3884Issue #3356842,!3812Draft: Issue #3339373 by alexpott, andypost, mondrake:...,!1459Issue #3087632: menu_name max length is too long
......@@ -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