diff --git a/modules/facets_exposed_filters/facets_exposed_filters.install b/modules/facets_exposed_filters/facets_exposed_filters.install index 94f0fe790e02b09fb8cda67f133eea780f5fcbd5..8be0cb9251ba42d41b5791ddd0666a5b9fbcf199 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 2012b8cdd349b7f0eaeb55ed5f8305283a438602..105ddbbaa848ab8e196784332b09df21246ac60e 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 93ff150443068f88f1d0744aa3b54d0aaeb771f3..aa4d5e190971e7ee4a5eb072fd1adb1730f69d24 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 902b554adaad29e19809f9e2dd830aedb1bbc337..a1965949606be6c92845a9ee9a2aa7291d38616c 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 daa5bac9cb155651ae1360014f1d191eb6edbe8e..3c9296c3da924552dd546b930badee63bb6bf957 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 79969eb3c86b46947e522a8008dffda38452d555..5f2f16970bcc009440825748236da374ad894c82 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 6712e5134d370e0bfefc6cd89e8f872a094cfce2..3004f17aab7b7d44b30eb1acd8c83cfabf86452d 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 75e7ae943570b99fe4c8199f0c22277004416463..dbcb5dfeee32fed955f091c952996aead1ce9821 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 f4cf01bb76df8f0b9782db5303989776137f7fa6..1ed4c35cf5bc6584d35e3935d5569d340f22ccaf 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 f0a155e22de4451b52680f234eb0be3493621d43..a3ea0a3b0e80a989c22ee989eb9f96f701f66d94 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 342703485276d48773218049846951f80c33ded1..007b4e3495884f01a4c8276371731e9b206db345 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 37e5e0bc894fa75f4275113eb7e268ba0e4dbc2c..251afe47ed2da3e304d71d6abb5d542252d2a43c 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 e1c223a7797d16de6d68d4370c2cd14ed85ef7bd..80089accbc8f59ec93ff7c7a20facb1b93e99b52 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 92a9028deb79e16fab3900bf02e2a70d7fea588e..8b930b0d2e94bba6fca95f29d51abdd5d070129f 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 6bc6ac0fe86bb1a775339d5f5e4b81dfa34a6ed5..00ce319266509ce66f4ffacda7e448c34553543f 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 99694280cf7d5bce3cd85242fd530016a75fdfda..076f1dba032b217ce33b92a1bc95e5b399c26e88 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 8c34d46ca702e5d7ded11fc78ebf1958d544a2f9..6c187e31f790609d57ddd038f4df5b86c94233ce 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 542832204240b6c3089075256bdc18d8a614b2cd..cc8121deaa88f8c10ea1f16df50843d518bc9519 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 63faf51e80d8730f3c5611ff382c5df74ccdf489..f6da0cfbdfdce3a97e94d52d7cb6aa733a8c30c7 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 89684874c72233adb88281336e28a1ef88ada55b..19fa4f665029ba0dd5d00946c8320af264fb10da 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 ae9ee4c97a314e7783ab12a390069b6212195ca4..baba3a3dbd86a5ba8268f7d4d08c14bbd71e462b 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 973513384aae3d409f2193d8ea2ee6df3e18b7b5..672524901b45735328b837bf65f9b375975c17a0 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 7b62848334a3dea21b98c5444179ee18d7a82efb..1d79e5cdf54586d62e899c6863e6396e7ad66da3 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; /**