function Node::defaultDisplayFiltersUser
Same name and namespace in other branches
- 9 core/modules/node/src/Plugin/views/wizard/Node.php \Drupal\node\Plugin\views\wizard\Node::defaultDisplayFiltersUser()
- 8.9.x core/modules/node/src/Plugin/views/wizard/Node.php \Drupal\node\Plugin\views\wizard\Node::defaultDisplayFiltersUser()
- 11.x core/modules/node/src/Plugin/views/wizard/Node.php \Drupal\node\Plugin\views\wizard\Node::defaultDisplayFiltersUser()
Overrides WizardPluginBase::defaultDisplayFiltersUser
File
-
core/
modules/ node/ src/ Plugin/ views/ wizard/ Node.php, line 158
Class
- Node
- Tests creating node views with the wizard.
Namespace
Drupal\node\Plugin\views\wizardCode
protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) {
$filters = parent::defaultDisplayFiltersUser($form, $form_state);
$tids = [];
if ($values = $form_state->getValue([
'show',
'tagged_with',
])) {
foreach ($values as $value) {
$tids[] = $value['target_id'];
}
}
if (!empty($tids)) {
$vid = reset($form['displays']['show']['tagged_with']['#selection_settings']['target_bundles']);
$filters['tid'] = [
'id' => 'tid',
'table' => 'taxonomy_index',
'field' => 'tid',
'value' => $tids,
'vid' => $vid,
'plugin_id' => 'taxonomy_index_tid',
];
// If the user entered more than one valid term in the autocomplete
// field, they probably intended both of them to be applied.
if (count($tids) > 1) {
$filters['tid']['operator'] = 'and';
// Sort the terms so the filter will be displayed as it normally would
// on the edit screen.
sort($filters['tid']['value']);
}
}
return $filters;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.