Commit d76bf402 authored by alexpott's avatar alexpott
Browse files

Issue #2202565 by rbayliss: Fixed Taxonomy default argument no longer works.

parent 5a520050
......@@ -125,14 +125,14 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$opti
public function getArgument() {
// Load default argument from taxonomy page.
if (!empty($this->options['term_page'])) {
if (($taxonomy_term = $this->request->attributes->get('taxonomy_term')) && $taxonomy_term instanceof TermInterface) {
if (($taxonomy_term = $this->view->getRequest()->attributes->get('taxonomy_term')) && $taxonomy_term instanceof TermInterface) {
return $taxonomy_term->id();
}
}
// Load default argument from node.
if (!empty($this->options['node'])) {
// Just check, if a node could be detected.
if (($node = $this->view->getRequest()->attributes->has('node')) && $node instanceof NodeInterface) {
if (($node = $this->view->getRequest()->attributes->get('node')) && $node instanceof NodeInterface) {
$taxonomy = array();
foreach ($node->getFieldDefinitions() as $field) {
if ($field->getType() == 'taxonomy_term_reference') {
......
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\Views\RelationshipRepresentativeNodeTest.
*/
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Tests the representative node relationship for terms.
*
* @group taxonomy
*/
class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('taxonomy_default_argument_test');
/**
* Tests the relationship.
*/
public function testNodePath() {
$view = Views::getView('taxonomy_default_argument_test');
$request = Request::create($this->nodes[0]->getSystemPath());
$response = $this->container->get('http_kernel')->handle($request, HttpKernelInterface::SUB_REQUEST);
$view->setRequest($request);
$view->setResponse($response);
$view->initHandlers();
$expected = implode(',', array($this->term1->id(), $this->term2->id()));
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
}
public function testTermPath() {
$view = Views::getView('taxonomy_default_argument_test');
$request = Request::create($this->term1->getSystemPath());
$response = $this->container->get('http_kernel')->handle($request, HttpKernelInterface::SUB_REQUEST);
$view->setRequest($request);
$view->setResponse($response);
$view->initHandlers();
$expected = $this->term1->id();
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
}
}
langcode: en
status: true
dependencies:
module:
- taxonomy
id: taxonomy_default_argument_test
label: taxonomy_default_argument_test
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: 'entity:taxonomy_term'
options:
relationship: none
view_mode: default
rendering_language: translation_language_renderer
provider: views
fields:
name:
id: name
table: taxonomy_term_data
field: name
provider: taxonomy
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
link_to_taxonomy: 1
relationship: none
group_type: group
admin_label: ''
dependencies: { }
exclude: 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_alter_empty: true
convert_spaces: false
filters: { }
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
tid:
id: tid
table: taxonomy_term_data
field: tid
relationship: none
group_type: group
admin_label: ''
dependencies:
module:
- taxonomy
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: taxonomy_tid
default_argument_options:
term_page: '1'
node: true
anyall: ','
limit: false
vids: { }
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
plugin_id: taxonomy
provider: taxonomy
field_langcode: '***LANGUAGE_site_default***'
field_langcode_add_to_query: null
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