From 0451e5b05937220a37365c9c7c5c40450049738d Mon Sep 17 00:00:00 2001 From: Herve Donner <hervedonner@gmail.com> Date: Tue, 28 Jan 2025 21:10:16 +0100 Subject: [PATCH] Fix PHPCS issues. --- .../facets_exposed_filters.install | 6 +++-- .../facets_exposed_filters.module | 20 +++++++++------- .../src/Plugin/views/filter/FacetsFilter.php | 23 +++++++++++------- .../src/Functional/ExposedFiltersTest.php | 11 ++++----- .../src/Plugin/Block/FacetsSummaryBlock.php | 2 +- .../processor/ShowCountProcessor.php | 2 +- .../views/FacetsSummaryViewsPluginTrait.php | 2 +- .../views/filter/FacetsSummaryFilter.php | 1 + src/Entity/Facet.php | 24 +++++++++++++------ src/Event/PostBuildFacet.php | 2 -- src/Plugin/Block/FacetBlock.php | 2 ++ .../facets/facet_source/SearchApiDisplay.php | 13 +++++----- .../processor/CombineFacetProcessor.php | 3 +++ .../processor/DependentFacetProcessor.php | 3 +++ .../HideInactiveSiblingsProcessor.php | 3 +++ .../ShowOnlyDeepestLevelItemsProcessor.php | 5 +++- .../processor/ShowSiblingsProcessor.php | 3 +++ .../facets/query_type/SearchApiDate.php | 7 +++++- .../facets/query_type/SearchApiString.php | 5 ++-- src/QueryType/QueryTypeRangeBase.php | 14 +++++++++-- .../Functional/Rest/FacetResourceTestBase.php | 6 +---- tests/src/FunctionalJavascript/JsBase.php | 10 ++++---- .../processor/ListItemProcessorTest.php | 5 ++++ 23 files changed, 113 insertions(+), 59 deletions(-) diff --git a/modules/facets_exposed_filters/facets_exposed_filters.install b/modules/facets_exposed_filters/facets_exposed_filters.install index 94f0fe79..8be0cb92 100644 --- a/modules/facets_exposed_filters/facets_exposed_filters.install +++ b/modules/facets_exposed_filters/facets_exposed_filters.install @@ -2,10 +2,11 @@ /** * @file + * Update hooks for the facets_exposed_filters module. */ /** - * 3446781: Migrate exposed filter facets to real views filters. + * Migrate exposed filter facets to real views filters (#3446781). */ function facets_exposed_filters_update_8001() { @@ -99,7 +100,8 @@ function facets_exposed_filters_update_8001() { } } - // Reset all facet_sources using url_processor views_exposed_filter to query_string. + // Reset all facet sources URL processor from views_exposed_filters to + // query_string. foreach ($config_factory->listAll('facets.facet_source.') as $facet_source_id) { $facet_source = $config_factory->getEditable($facet_source_id); if ($facet_source->get('url_processor') == 'views_exposed_filters') { diff --git a/modules/facets_exposed_filters/facets_exposed_filters.module b/modules/facets_exposed_filters/facets_exposed_filters.module index 2012b8cd..105ddbba 100644 --- a/modules/facets_exposed_filters/facets_exposed_filters.module +++ b/modules/facets_exposed_filters/facets_exposed_filters.module @@ -2,12 +2,14 @@ /** * @file + * Contains facets_exposed_filters.module. */ use Drupal\Core\Block\BlockPluginInterface; use Drupal\search_api\Entity\Index; use Drupal\search_api\Plugin\views\query\SearchApiQuery; use Drupal\search_api\Query\QueryInterface; +use Drupal\views\Plugin\Block\ViewsExposedFilterBlock; use Drupal\views\Plugin\views\filter\FilterPluginBase; use Drupal\views\ViewExecutable; @@ -57,7 +59,8 @@ function facets_exposed_filters_search_api_query_alter(QueryInterface $query) { 'operator' => $filter->options["facet"]["query_operator"], 'min_count' => $filter->options["facet"]["min_count"], 'missing' => FALSE, - 'query_type' => 'search_api_string', // TODO: investigate if this property (query_type) is used. + // @todo Investigate if this property (query_type) is used. + 'query_type' => 'search_api_string', ]; } } @@ -81,8 +84,7 @@ function facets_exposed_filters_remove_validation($element, $form) { * Implements hook_views_post_execute(). */ function facets_exposed_filters_views_post_execute(ViewExecutable $view) { - - // No need to alter if no exposed widgets are present and we are not using exposed block. + // Skip if no exposed widgets are present and we are not using exposed block. if (!$view->exposed_widgets && !$view->display_handler->getOption('exposed_block')) { return; } @@ -96,8 +98,8 @@ function facets_exposed_filters_views_post_execute(ViewExecutable $view) { $search_api_facets = $search_api_results->getExtraData('search_api_facets'); $view->facets_query_post_execute = TRUE; - // If we have facet results, attach them. If no results are returned, we still need to rerender, as there can still be - // active filters (without results). + // If we have facet results, attach them. If no results are returned, we still + // need to rerender, as there can still be active filters (without results). if ($search_api_facets) { // Attach facet results to views, so we can use them in FacetsFilter. foreach ($view->filter as $search_api_id => $filter) { @@ -168,9 +170,9 @@ function facets_exposed_filters_get_processed_facet($view_id, $display_id, $filt * Implements hook_block_build_alter(). */ function facets_exposed_filters_block_build_alter(array &$build, BlockPluginInterface $block) { - // Exposed filter blocks can be placed on any page. We need to ensure that the view is executed when the block is - // rendered and has Facet filters. - if($block instanceof \Drupal\views\Plugin\Block\ViewsExposedFilterBlock) { + // Exposed filter blocks can be placed on any page. We need to ensure that the + // view is executed when the block is rendered and has Facet filters. + if ($block instanceof ViewsExposedFilterBlock) { $view = $block->getViewExecutable(); $view->initHandlers(); foreach ($view->filter as $filter) { @@ -178,7 +180,7 @@ function facets_exposed_filters_block_build_alter(array &$build, BlockPluginInte $filter_id = $filter->options["id"]; $display = $view->current_display; $processed_facet = facets_exposed_filters_get_processed_facet($view->id(), $display, $filter_id); - if(!$processed_facet) { + if (!$processed_facet) { // The facet has not been processed. $view->execute($display); } diff --git a/modules/facets_exposed_filters/src/Plugin/views/filter/FacetsFilter.php b/modules/facets_exposed_filters/src/Plugin/views/filter/FacetsFilter.php index 93ff1504..aa4d5e19 100644 --- a/modules/facets_exposed_filters/src/Plugin/views/filter/FacetsFilter.php +++ b/modules/facets_exposed_filters/src/Plugin/views/filter/FacetsFilter.php @@ -11,7 +11,6 @@ use Drupal\facets\FacetInterface; use Drupal\facets\Hierarchy\HierarchyPluginBase; use Drupal\facets\Processor\ProcessorInterface; use Drupal\facets\Processor\SortProcessorInterface; -use Drupal\facets\Result\Result; use Drupal\views\Plugin\views\filter\FilterPluginBase; /** @@ -26,11 +25,15 @@ class FacetsFilter extends FilterPluginBase { /** * {@inheritdoc} */ + // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName public $no_operator = FALSE; /** - * Will be filled with the facet results after the query is executed. + * Stores the facet results after the query is executed. + * + * @var \Drupal\facets\Result\ResultInterface[] */ + // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName public $facet_results = []; /** @@ -103,7 +106,7 @@ class FacetsFilter extends FilterPluginBase { return $form; } - // Retrieve the processed facet if we already done this in the current request. + // Retrieve the processed facet if already handled in the current request. $processed_facet = facets_exposed_filters_get_processed_facet($this->view->id(), $this->view->current_display, $this->options["id"]); // Empty facet results, return empty form. @@ -134,8 +137,8 @@ class FacetsFilter extends FilterPluginBase { ); $query_type_plugin->build(); - // When no results are available, we do not need to process the facet or render the form item. - if(!$facet->getResults()) { + // Skip facet processing and form rendering if there are no results. + if (!$facet->getResults()) { return; } @@ -151,7 +154,7 @@ class FacetsFilter extends FilterPluginBase { $facet->setResults($processor->build($facet, $facet->getResults())); } - // Trigger sort stage and sort the actual results with the sort processors. + // Allow processors to sort the results. $active_sort_processors = []; foreach ($facet->getProcessorsByStage(ProcessorInterface::STAGE_SORT) as $processor) { $active_sort_processors[] = $processor; @@ -161,7 +164,8 @@ class FacetsFilter extends FilterPluginBase { } $facet->setActiveItems(array_values($active_facet_values)); - // Store the processed facet so we can access it later (e.g. in an exposed form rendered as a block). + // Store the processed facet so we can access it later (e.g. in an exposed + // form rendered as a block). facets_exposed_filters_get_processed_facet($this->view->id(), $this->view->current_display, $this->options["id"], $facet); } @@ -546,8 +550,9 @@ class FacetsFilter extends FilterPluginBase { * to retrieve the active filters from the request ourself. */ private function getActiveFacetValues() { - // Reset button in ajax request. We probably want a better way to detect if this was clicked. - if(isset($_GET["reset"])) { + // Reset button in ajax request. We probably want a better way to detect if + // this was clicked. + if (isset($_GET["reset"])) { return []; } $exposed = $this->view->getExposedInput(); diff --git a/modules/facets_exposed_filters/tests/src/Functional/ExposedFiltersTest.php b/modules/facets_exposed_filters/tests/src/Functional/ExposedFiltersTest.php index 902b554a..a1965949 100644 --- a/modules/facets_exposed_filters/tests/src/Functional/ExposedFiltersTest.php +++ b/modules/facets_exposed_filters/tests/src/Functional/ExposedFiltersTest.php @@ -40,7 +40,6 @@ class ExposedFiltersTest extends FacetsTestBase { * Tests slider widget. */ public function testExposedFilters() { - // Test non-filtered page. $this->drupalGet('test-facets-exposed-filters'); $this->assertSession()->pageTextContains('Keywords'); @@ -48,18 +47,18 @@ class ExposedFiltersTest extends FacetsTestBase { $this->assertSession()->pageTextContains('strawberry'); // Test filtered page. - $this->drupalGet('test-facets-exposed-filters',['query' => ['keywords[]' => 'apple']] ); + $this->drupalGet('test-facets-exposed-filters', ['query' => ['keywords[]' => 'apple']]); $this->assertSession()->pageTextContains('Keywords'); $this->assertSession()->pageTextNotContains('entity:entity_test_mulrev_changed/3:en'); $this->assertSession()->pageTextContains('strawberry'); - // Test if facet in keywords disappears when non-matching category is selected. - $this->drupalGet('test-facets-exposed-filters',['query' => ['category[]' => 'item_category']] ); + // Test if facet item disappears when non-matching category is selected. + $this->drupalGet('test-facets-exposed-filters', ['query' => ['category[]' => 'item_category']]); $this->assertSession()->pageTextContains('Keywords'); $this->assertSession()->pageTextNotContains('strawberry'); - // Test if facet in keywords stays when matching category is selected. - $this->drupalGet('test-facets-exposed-filters',['query' => ['category[]' => 'article_category']] ); + // Test if facet item remains when matching category is selected. + $this->drupalGet('test-facets-exposed-filters', ['query' => ['category[]' => 'article_category']]); $this->assertSession()->pageTextContains('Keywords'); $this->assertSession()->pageTextContains('strawberry'); } diff --git a/modules/facets_summary/src/Plugin/Block/FacetsSummaryBlock.php b/modules/facets_summary/src/Plugin/Block/FacetsSummaryBlock.php index daa5bac9..3c9296c3 100644 --- a/modules/facets_summary/src/Plugin/Block/FacetsSummaryBlock.php +++ b/modules/facets_summary/src/Plugin/Block/FacetsSummaryBlock.php @@ -152,7 +152,7 @@ class FacetsSummaryBlock extends BlockBase implements FacetsSummaryBlockInterfac } /** - * @throws \Drupal\facets\Exception\InvalidProcessorException + * Calculates the cache dependencies for this block instance. */ protected function calculateCacheDependencies(): void { if (!$this->cacheableMetadata) { diff --git a/modules/facets_summary/src/Plugin/facets_summary/processor/ShowCountProcessor.php b/modules/facets_summary/src/Plugin/facets_summary/processor/ShowCountProcessor.php index 79969eb3..5f2f1697 100644 --- a/modules/facets_summary/src/Plugin/facets_summary/processor/ShowCountProcessor.php +++ b/modules/facets_summary/src/Plugin/facets_summary/processor/ShowCountProcessor.php @@ -31,7 +31,7 @@ class ShowCountProcessor extends ProcessorPluginBase implements BuildProcessorIn $count = $facets_summary->getFacetSource()->getCount(); $build_count = [ '#theme' => 'facets_summary_count', - '#count' => $count === NULL ? 0 : $count, + '#count' => $count ?? 0, ]; array_unshift($build['#items'], $build_count); return $build; diff --git a/modules/facets_summary/src/Plugin/views/FacetsSummaryViewsPluginTrait.php b/modules/facets_summary/src/Plugin/views/FacetsSummaryViewsPluginTrait.php index 6712e513..3004f17a 100644 --- a/modules/facets_summary/src/Plugin/views/FacetsSummaryViewsPluginTrait.php +++ b/modules/facets_summary/src/Plugin/views/FacetsSummaryViewsPluginTrait.php @@ -37,7 +37,7 @@ trait FacetsSummaryViewsPluginTrait { '#options' => $options, '#type' => 'radios', '#required' => TRUE, - '#default_value' => isset($this->options['facet_summary']) ? $this->options['facet_summary'] : [], + '#default_value' => $this->options['facet_summary'] ?? [], ]; $form['label_display'] = [ diff --git a/modules/facets_summary/src/Plugin/views/filter/FacetsSummaryFilter.php b/modules/facets_summary/src/Plugin/views/filter/FacetsSummaryFilter.php index 75e7ae94..dbcb5dfe 100644 --- a/modules/facets_summary/src/Plugin/views/filter/FacetsSummaryFilter.php +++ b/modules/facets_summary/src/Plugin/views/filter/FacetsSummaryFilter.php @@ -25,6 +25,7 @@ class FacetsSummaryFilter extends FilterPluginBase { /** * {@inheritdoc} */ + // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName public $no_operator = TRUE; /** diff --git a/src/Entity/Facet.php b/src/Entity/Facet.php index f4cf01bb..1ed4c35c 100644 --- a/src/Entity/Facet.php +++ b/src/Entity/Facet.php @@ -324,7 +324,12 @@ class Facet extends ConfigEntityBase implements FacetInterface { */ protected $min_count = 1; - protected $cache_dependencies_calculated = FALSE; + /** + * Tracks whether the cache dependencies have been calculated. + * + * @var bool + */ + protected $cacheDependenciesCalculated = FALSE; /** * The missing parameter. @@ -496,9 +501,10 @@ class Facet extends ConfigEntityBase implements FacetInterface { $query_types = $facet_source->getQueryTypesForFacet($this); - // Allow Facets without widgets (e.g. for facets exposed filters, where views handles the widget part). + // Allow Facets without widgets (e.g. for facets exposed filters, where + // views handles the widget part). $widgetQueryType = NULL; - if($this->widget != "<nowidget>") { + if ($this->widget != "<nowidget>") { // Get the widget configured for this facet. /** @var \Drupal\facets\Widget\WidgetPluginInterface $widget */ $widget = $this->getWidgetInstance(); @@ -717,6 +723,7 @@ class Facet extends ConfigEntityBase implements FacetInterface { public function getName() { return $this->name; } + /** * {@inheritdoc} */ @@ -1019,7 +1026,7 @@ class Facet extends ConfigEntityBase implements FacetInterface { // Sort the processors, so we won't have unnecessary changes. ksort($this->processor_configs); - $this->cache_dependencies_calculated = FALSE; + $this->cacheDependenciesCalculated = FALSE; } /** @@ -1029,7 +1036,7 @@ class Facet extends ConfigEntityBase implements FacetInterface { unset($this->processor_configs[$processor_id]); unset($this->processors[$processor_id]); - $this->cache_dependencies_calculated = FALSE; + $this->cacheDependenciesCalculated = FALSE; } /** @@ -1219,8 +1226,11 @@ class Facet extends ConfigEntityBase implements FacetInterface { return $this->cacheMaxAge; } + /** + * Calculates the cache dependencies for this facet entity. + */ protected function calculateCacheDependencies(): void { - if (!$this->cache_dependencies_calculated) { + if (!$this->cacheDependenciesCalculated) { if ($facet_source = $this->getFacetSource()) { $this->addCacheableDependency($facet_source); } @@ -1229,7 +1239,7 @@ class Facet extends ConfigEntityBase implements FacetInterface { $this->addCacheableDependency($processor); } - $this->cache_dependencies_calculated = TRUE; + $this->cacheDependenciesCalculated = TRUE; } } diff --git a/src/Event/PostBuildFacet.php b/src/Event/PostBuildFacet.php index f0a155e2..a3ea0a3b 100644 --- a/src/Event/PostBuildFacet.php +++ b/src/Event/PostBuildFacet.php @@ -45,8 +45,6 @@ final class PostBuildFacet extends Event { * * @param \Drupal\facets\FacetInterface $facet * The facet. - * - * @return void */ public function setFacet(FacetInterface $facet): void { $this->facet = $facet; diff --git a/src/Plugin/Block/FacetBlock.php b/src/Plugin/Block/FacetBlock.php index 34270348..007b4e34 100644 --- a/src/Plugin/Block/FacetBlock.php +++ b/src/Plugin/Block/FacetBlock.php @@ -39,6 +39,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface { protected $facetStorage; /** + * The facet being displayed. + * * @var \Drupal\facets\FacetInterface */ protected $facet; diff --git a/src/Plugin/facets/facet_source/SearchApiDisplay.php b/src/Plugin/facets/facet_source/SearchApiDisplay.php index 37e5e0bc..251afe47 100644 --- a/src/Plugin/facets/facet_source/SearchApiDisplay.php +++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php @@ -88,7 +88,7 @@ class SearchApiDisplay extends FacetSourcePluginBase implements SearchApiFacetSo * * @var bool */ - protected $display_edit_in_progress = FALSE; + protected $displayEditInProgress = FALSE; /** * Constructs a SearchApiBaseFacetSource object. @@ -575,19 +575,20 @@ class SearchApiDisplay extends FacetSourcePluginBase implements SearchApiFacetSo * Is the display currently edited and saved? * * @return bool + * Whether the display being edited. */ public function isDisplayEditInProgress(): bool { - return $this->display_edit_in_progress; + return $this->displayEditInProgress; } /** * Set the state, that the display is currently edited and saved. * - * @param bool $display_edit_in_progress - * True if the display being edited. + * @param bool $value + * Sets whether the display being edited. */ - public function setDisplayEditInProgress(bool $display_edit_in_progress): void { - $this->display_edit_in_progress = $display_edit_in_progress; + public function setDisplayEditInProgress(bool $value): void { + $this->displayEditInProgress = $value; } } diff --git a/src/Plugin/facets/processor/CombineFacetProcessor.php b/src/Plugin/facets/processor/CombineFacetProcessor.php index e1c223a7..80089acc 100644 --- a/src/Plugin/facets/processor/CombineFacetProcessor.php +++ b/src/Plugin/facets/processor/CombineFacetProcessor.php @@ -171,6 +171,9 @@ class CombineFacetProcessor extends ProcessorPluginBase implements BuildProcesso return $results; } + /** + * {@inheritdoc} + */ public function supportsFacet(FacetInterface $facet) { // Only support facets as entities, not e.g. facets_exposed_filters. return $facet->getFacetType() == 'facet_entity'; diff --git a/src/Plugin/facets/processor/DependentFacetProcessor.php b/src/Plugin/facets/processor/DependentFacetProcessor.php index 92a9028d..8b930b0d 100644 --- a/src/Plugin/facets/processor/DependentFacetProcessor.php +++ b/src/Plugin/facets/processor/DependentFacetProcessor.php @@ -222,6 +222,9 @@ class DependentFacetProcessor extends ProcessorPluginBase implements BuildProces return $return; } + /** + * {@inheritdoc} + */ public function supportsFacet(FacetInterface $facet) { // Only support facets as entities, not e.g. facets_exposed_filters. return $facet->getFacetType() == 'facet_entity'; diff --git a/src/Plugin/facets/processor/HideInactiveSiblingsProcessor.php b/src/Plugin/facets/processor/HideInactiveSiblingsProcessor.php index 6bc6ac0f..00ce3192 100644 --- a/src/Plugin/facets/processor/HideInactiveSiblingsProcessor.php +++ b/src/Plugin/facets/processor/HideInactiveSiblingsProcessor.php @@ -62,6 +62,9 @@ class HideInactiveSiblingsProcessor extends ProcessorPluginBase implements Build return $results; } + /** + * {@inheritdoc} + */ public function supportsFacet(FacetInterface $facet) { return $facet->getFacetType() == 'facet_entity'; } diff --git a/src/Plugin/facets/processor/ShowOnlyDeepestLevelItemsProcessor.php b/src/Plugin/facets/processor/ShowOnlyDeepestLevelItemsProcessor.php index 99694280..076f1dba 100644 --- a/src/Plugin/facets/processor/ShowOnlyDeepestLevelItemsProcessor.php +++ b/src/Plugin/facets/processor/ShowOnlyDeepestLevelItemsProcessor.php @@ -36,8 +36,11 @@ class ShowOnlyDeepestLevelItemsProcessor extends ProcessorPluginBase implements return $results; } + /** + * {@inheritdoc} + */ public function supportsFacet(FacetInterface $facet) { - // TODO: Support "facets_exposed_filter". + // @todo Support "facets_exposed_filter". return $facet->getFacetType() == 'facet_entity'; } diff --git a/src/Plugin/facets/processor/ShowSiblingsProcessor.php b/src/Plugin/facets/processor/ShowSiblingsProcessor.php index 8c34d46c..6c187e31 100644 --- a/src/Plugin/facets/processor/ShowSiblingsProcessor.php +++ b/src/Plugin/facets/processor/ShowSiblingsProcessor.php @@ -68,6 +68,9 @@ class ShowSiblingsProcessor extends ProcessorPluginBase implements BuildProcesso return $build; } + /** + * {@inheritdoc} + */ public function supportsFacet(FacetInterface $facet) { return $facet->getFacetType() == 'facet_entity'; } diff --git a/src/Plugin/facets/query_type/SearchApiDate.php b/src/Plugin/facets/query_type/SearchApiDate.php index 54283220..cc8121de 100644 --- a/src/Plugin/facets/query_type/SearchApiDate.php +++ b/src/Plugin/facets/query_type/SearchApiDate.php @@ -108,7 +108,8 @@ class SearchApiDate extends QueryTypeRangeBase { $configuration['granularity'] = $granularity; $this->setConfiguration($configuration); - // Add unprocessed active values to the result. These are selected items that do not match the results anymore. + // Add unprocessed active values to the result. These are selected items + // that do not match the results anymore. $active_items = $this->facet->getActiveItems(); foreach ($active_items as $val) { if (!isset($facet_results[$val])) { @@ -267,6 +268,10 @@ class SearchApiDate extends QueryTypeRangeBase { return $this->calculateResultFilterAbsolute($value); } } + + /** + * {@inheritdoc} + */ public function getDisplayValue($raw_value) { $dateTime = new DrupalDateTime(); switch ($this->getGranularity()) { diff --git a/src/Plugin/facets/query_type/SearchApiString.php b/src/Plugin/facets/query_type/SearchApiString.php index 63faf51e..f6da0cfb 100644 --- a/src/Plugin/facets/query_type/SearchApiString.php +++ b/src/Plugin/facets/query_type/SearchApiString.php @@ -82,7 +82,7 @@ class SearchApiString extends QueryTypePluginBase { if ($result_filter[strlen($result_filter) - 1] === '"') { $result_filter = substr($result_filter, 0, -1); } - if (($key = array_search($result_filter, $unprocessed_active_items)) !== false) { + if (($key = array_search($result_filter, $unprocessed_active_items)) !== FALSE) { unset($unprocessed_active_items[$key]); } $count = $result['count']; @@ -92,7 +92,8 @@ class SearchApiString extends QueryTypePluginBase { } } - // Add unprocessed active values to the result. These are selected items that do not match the results anymore. + // Add unprocessed active values to the result. These are selected items + // that do not match the results anymore. foreach ($unprocessed_active_items as $val) { $result = new Result($this->facet, $val, $val, 0); $result->setActiveState(TRUE); diff --git a/src/QueryType/QueryTypeRangeBase.php b/src/QueryType/QueryTypeRangeBase.php index 89684874..19fa4f66 100644 --- a/src/QueryType/QueryTypeRangeBase.php +++ b/src/QueryType/QueryTypeRangeBase.php @@ -91,7 +91,7 @@ abstract class QueryTypeRangeBase extends QueryTypePluginBase { else { $facet_results[$result_filter['raw']] = new Result($this->facet, $result_filter['raw'], $result_filter['display'], $count); } - if (($key = array_search($result_filter['raw'], $unprocessed_active_items)) !== false) { + if (($key = array_search($result_filter['raw'], $unprocessed_active_items)) !== FALSE) { unset($unprocessed_active_items[$key]); } } @@ -99,7 +99,8 @@ abstract class QueryTypeRangeBase extends QueryTypePluginBase { } if (!$this->getHierarchy()) { - // Add unprocessed active values to the result. These are selected items that do not match the results anymore. + // Add unprocessed active values to the result. These are selected items + // that do not match the results anymore. foreach ($unprocessed_active_items as $val) { $result = new Result($this->facet, $val, $this->getDisplayValue($val), 0); $result->setActiveState(TRUE); @@ -111,6 +112,15 @@ abstract class QueryTypeRangeBase extends QueryTypePluginBase { return $this->facet; } + /** + * Returns the display value for the given raw value. + * + * @param mixed $raw_value + * The raw value. + * + * @return mixed + * The display value. + */ public function getDisplayValue($raw_value) { return $raw_value; } diff --git a/tests/src/Functional/Rest/FacetResourceTestBase.php b/tests/src/Functional/Rest/FacetResourceTestBase.php index ae9ee4c9..baba3a3d 100644 --- a/tests/src/Functional/Rest/FacetResourceTestBase.php +++ b/tests/src/Functional/Rest/FacetResourceTestBase.php @@ -116,11 +116,7 @@ abstract class FacetResourceTestBase extends EntityResourceTestBase { } /** - * The expected cache contexts for the GET/HEAD response of the test entity. - * - * @see ::testGet - * - * @return string[] + * {@inheritdoc} */ protected function getExpectedCacheContexts() { return array_merge(parent::getExpectedCacheContexts(), [ diff --git a/tests/src/FunctionalJavascript/JsBase.php b/tests/src/FunctionalJavascript/JsBase.php index 97351338..67252490 100644 --- a/tests/src/FunctionalJavascript/JsBase.php +++ b/tests/src/FunctionalJavascript/JsBase.php @@ -151,10 +151,12 @@ abstract class JsBase extends WebDriverTestBase { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * @throws \Drupal\Core\Entity\EntityStorageException */ - protected function createFacet($id, $field = 'type', $widget_type = 'links', array $widget_settings = [ - 'show_numbers' => TRUE, - 'soft_limit' => 0, - ]) { + protected function createFacet( + $id, + $field = 'type', + $widget_type = 'links', + array $widget_settings = ['show_numbers' => TRUE, 'soft_limit' => 0], + ) { $facet_storage = \Drupal::entityTypeManager()->getStorage('facets_facet'); // Create and save a facet with a checkbox widget. $facet_storage->create([ diff --git a/tests/src/Unit/Plugin/processor/ListItemProcessorTest.php b/tests/src/Unit/Plugin/processor/ListItemProcessorTest.php index 7b628483..1d79e5cd 100644 --- a/tests/src/Unit/Plugin/processor/ListItemProcessorTest.php +++ b/tests/src/Unit/Plugin/processor/ListItemProcessorTest.php @@ -42,6 +42,11 @@ class ListItemProcessorTest extends UnitTestCase { */ protected $results; + /** + * The processor plugin manager. + * + * @var \Drupal\facets_summary\Processor\ProcessorPluginManager + */ protected $processorPluginManager; /** -- GitLab