diff -u b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php --- b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -29,6 +29,7 @@ * * @var array|null */ + // @codingStandardsIgnoreLine public $validated_exposed_input = NULL; /** @@ -73,6 +74,7 @@ $this->vocabularyStorage = $vocabulary_storage; $this->termStorage = $term_storage; if (!$current_user) { + // @codingStandardsIgnoreLine @trigger_error('The current_user service must be passed to ' . __NAMESPACE__ . '\TaxonomyIndexTid::__construct(). It was added in drupal:8.9.0 and will be required before drupal:10.0.0.', E_USER_DEPRECATED); $current_user = \Drupal::service('current_user'); } @@ -135,6 +137,9 @@ return $entity_ids; } + /** + * {@inheritdoc} + */ public function hasExtraOptions() { return TRUE; } @@ -146,6 +151,9 @@ return $this->valueOptions; } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -158,6 +166,9 @@ return $options; } + /** + * {@inheritdoc} + */ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { $vocabularies = $this->vocabularyStorage->loadMultiple(); $options = []; @@ -186,7 +197,10 @@ $form['type'] = [ '#type' => 'radios', '#title' => $this->t('Selection type'), - '#options' => ['select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')], + '#options' => [ + 'select' => $this->t('Dropdown'), + 'textfield' => $this->t('Autocomplete'), + ], '#default_value' => $this->options['type'], ]; @@ -202,6 +216,9 @@ ]; } + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { $vocabulary = $this->getVocabulary(); if (empty($vocabulary) && $this->options['limit']) { @@ -250,7 +267,7 @@ } if (!$form_state->get('exposed')) { - // Retain the helper option + // Retain the helper option. $this->helper->buildOptionsForm($form, $form_state); // Show help text if not exposed to end users. @@ -282,6 +299,9 @@ return $form_value; } + /** + * {@inheritdoc} + */ protected function getFormValueOptions() { if (!empty($this->options['hierarchy']) && $this->options['limit']) { return $this->getFormValueOptionsWithHierarchyAndLimit(); @@ -369,6 +389,9 @@ } } + /** + * {@inheritdoc} + */ protected function valueValidate($form, FormStateInterface $form_state) { // We only validate if they've chosen the text field style. if ($this->options['type'] != 'textfield') { @@ -384,6 +407,9 @@ $form_state->setValue(['options', 'value'], $tids); } + /** + * {@inheritdoc} + */ public function acceptExposedInput($input) { if (empty($this->options['exposed'])) { return TRUE; @@ -396,7 +422,7 @@ } // If view is an attachment and is inheriting exposed filters, then assume - // exposed input has already been validated + // exposed input has already been validated. if (!empty($this->view->is_attachment) && $this->view->display_handler->usesExposed()) { $this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']]; } @@ -423,6 +449,9 @@ return $rc; } + /** + * {@inheritdoc} + */ public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; @@ -455,8 +484,11 @@ } } + /** + * {@inheritdoc} + */ protected function valueSubmit($form, FormStateInterface $form_state) { - // prevent array_filter from messing up our arrays in parent submit. + // Prevent array_filter from messing up our arrays in parent submit. $term_ids = $form_state->getValue(['options', 'value']); $uuids = []; @@ -467,6 +499,9 @@ $form_state->setValue(['options', 'value'], $uuids); } + /** + * {@inheritdoc} + */ public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); if ($this->options['type'] != 'select') { @@ -479,8 +514,11 @@ ]; } + /** + * {@inheritdoc} + */ public function adminSummary() { - // set up $this->valueOptions for the parent summary + // Set up $this->valueOptions for the parent summary. $this->valueOptions = []; if ($this->value) { @@ -526,7 +564,7 @@ /** * Get the vocabulary entity given a vocabulary ID. * - * @return \Drupal\taxonomy\VocabularyInterface + * @return \Drupal\Core\Entity\EntityInterface * The vocabulary matching the given vocabulary ID. */ protected function getVocabulary() { diff -u b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php --- b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php @@ -57,6 +57,8 @@ /** * {@inheritdoc} + * + * @throws \Drupal\Core\Entity\EntityStorageException */ protected function setUp($import_test_views = TRUE, $modules = []): void { parent::setUp($import_test_views, $modules); @@ -78,7 +80,7 @@ // - term 1.1 // term 2.0 // - term 2.1 - // - term 2.2 + // - term 2.2. for ($i = 0; $i < 3; $i++) { for ($j = 0; $j <= $i; $j++) { $this->terms[$i][$j] = $term = Term::create([ @@ -99,7 +101,11 @@ /** * Tests the filter UI. + * + * @throws \Behat\Mink\Exception\ElementNotFoundException + * @throws \Drupal\Core\Entity\EntityStorageException */ + // @codingStandardsIgnoreLine public function testFilterUI() { $this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid'); @@ -143,6 +149,10 @@ /** * Tests exposed taxonomy filters. + * + * @throws \Behat\Mink\Exception\ResponseTextException + * @throws \Behat\Mink\Exception\ExpectationException + * @throws \Drupal\Core\Entity\EntityMalformedException */ public function testExposedFilter() { $node_type = $this->drupalCreateContentType(['type' => 'page']); @@ -280,6 +290,8 @@ /** * Tests exposed grouped taxonomy filters. + * + * @throws \Behat\Mink\Exception\ResponseTextException */ public function testExposedGroupedFilter() { // Create a content type with a taxonomy field. @@ -297,9 +309,18 @@ $this->drupalGet('/admin/structure/views/nojs/handler/test_taxonomy_exposed_grouped_filter/page_1/filter/field_views_testing_tags_target_id'); $edit = [ - 'options[group_info][group_items][1][value][]' => [$this->terms[0][0]->id(), $this->terms[1][0]->id()], - 'options[group_info][group_items][2][value][]' => [$this->terms[1][0]->id(), $this->terms[2][0]->id()], - 'options[group_info][group_items][3][value][]' => [$this->terms[2][0]->id(), $this->terms[0][0]->id()], + 'options[group_info][group_items][1][value][]' => [ + $this->terms[0][0]->id(), + $this->terms[1][0]->id(), + ], + 'options[group_info][group_items][2][value][]' => [ + $this->terms[1][0]->id(), + $this->terms[2][0]->id(), + ], + 'options[group_info][group_items][3][value][]' => [ + $this->terms[2][0]->id(), + $this->terms[0][0]->id(), + ], ]; $this->submitForm($edit, 'Apply'); $this->submitForm([], 'Save'); @@ -324,6 +345,8 @@ /** * Tests that an exposed taxonomy filter doesn't show unpublished terms. + * + * @throws \Drupal\Core\Entity\EntityStorageException */ public function testExposedUnpublishedFilterOptions() { $this->terms[1][0]->setUnpublished()->save();