Issue #2252739 by Gábor Hojtsy, rbayliss: Fixed Taxonomy field handler fatal error in linking to terms, cannot create taxonomy views with defaults.

8.0.x
Alex Pott 2014-08-13 18:15:35 -07:00
parent 37df1bd026
commit fb27c45f6a
3 changed files with 215 additions and 6 deletions

View File

@ -77,12 +77,9 @@ class Taxonomy extends FieldPluginBase {
* Returns a string for the link text.
*/
protected function renderLink($data, ResultRow $values) {
$tid = $this->getValue($values, 'tid');
if (!empty($this->options['link_to_taxonomy']) && !empty($tid) && $data !== NULL && $data !== '') {
$term = entity_create('taxonomy_term', array(
'tid' => $tid,
'vid' => $this->getValue($values, 'vid'),
));
$term = $this->getEntity($values);
if (!empty($this->options['link_to_taxonomy']) && $term && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $term->getSystemPath();
}

View File

@ -0,0 +1,36 @@
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldTidTest.
*/
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
/**
* Tests the taxonomy term TID field handler.
*
* @group taxonomy
*/
class TaxonomyFieldTidTest extends TaxonomyTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_taxonomy_tid_field');
function testViewsHandlerTidField() {
$view = Views::getView('test_taxonomy_tid_field');
$this->executeView($view);
$actual = $view->field['name']->advancedRender($view->result[0]);
$expected = l($this->term1->label(), $this->term1->getSystemPath());
$this->assertEqual($expected, $actual);
}
}

View File

@ -0,0 +1,176 @@
langcode: en
status: true
dependencies:
module:
- taxonomy
id: test_taxonomy_tid_field
label: test_taxonomy_tid_field
module: views
description: ''
tag: ''
base_table: taxonomy_term_data
base_field: tid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
provider: views
display_options:
access:
type: perm
options:
perm: 'access content'
provider: user
dependencies: { }
cache:
type: none
options: { }
provider: views
dependencies: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: false
query_tags: { }
provider: views
dependencies: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
provider: views
dependencies: { }
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 20, 40, 60'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: '« first'
last: 'last »'
quantity: 9
provider: views
dependencies: { }
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
provider: views
dependencies: { }
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
provider: views
dependencies: { }
fields:
name:
id: name
table: taxonomy_term_field_data
field: name
relationship: none
group_type: group
admin_label: ''
dependencies:
module:
- taxonomy
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: ''
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
link_to_taxonomy: true
convert_spaces: false
plugin_id: taxonomy
provider: taxonomy
filters: { }
sorts:
tid:
id: tid
table: taxonomy_term_data
field: tid
relationship: none
group_type: group
admin_label: ''
dependencies:
module:
- views
order: ASC
exposed: false
expose:
label: ''
plugin_id: standard
provider: views
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
field_langcode: '***CURRENT_LANGUAGE***'
field_langcode_add_to_query: null