Commit 7623ba8b authored by borisson_'s avatar borisson_

Issue #2588731: Interfaces for processors + add default widgetconfig processor...

Issue #2588731: Interfaces for processors + add default widgetconfig processor + move url processor to processor
parent ebc07552
......@@ -32,3 +32,21 @@ facetapi.facet.*:
sequence:
type: string
label: 'Widget plugin configurations'
processor_configs:
type: sequence
label: 'Processor settings'
sequence:
type: mapping
label: 'A processor'
mapping:
processor_id:
type: string
label: 'The plugin ID of the processor'
weights:
type: sequence
label: 'The processor''s weights for the different processing stages'
sequence:
type: integer
label: 'The processor''s weight for this stage'
settings:
type: facetapi.processor.plugin.[%parent.processor_id]
facetapi.processor.plugin.count_widget_order:
type: mapping
label: 'Count widget order'
mapping:
enabled:
type: boolean
label: 'Is the widget enabled?'
sort:
type: string
label: sort order
......@@ -5,15 +5,15 @@ services:
plugin.manager.facetapi.query_type:
class: Drupal\facetapi\QueryType\QueryTypePluginManager
parent: default_plugin_manager
plugin.manager.facetapi.url_processor:
class: Drupal\facetapi\UrlProcessor\UrlProcessorPluginManager
parent: default_plugin_manager
plugin.manager.facetapi.widget:
class: Drupal\facetapi\Widget\WidgetPluginManager
parent: default_plugin_manager
plugin.manager.facetapi.facet_source:
class: Drupal\facetapi\FacetSource\FacetSourcePluginManager
parent: default_plugin_manager
plugin.manager.facetapi.processor:
class: Drupal\facetapi\Processor\ProcessorPluginManager
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@string_translation']
search_api_facets.get_facets:
class: \Drupal\facetapi\GetFacets
arguments:
......
<?php
/**
* @file
* Contains \Drupal\facetapi\Annotation\FacetApiProcessor.
*/
namespace Drupal\facetapi\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facet API Processor annotation object.
*
* @see \Drupal\facetapi\Processor\ProcessorPluginManager
* @see plugin_api
*
* @ingroup plugin_api
*
* @Annotation
*/
class FacetApiProcessor extends Plugin {
/**
* The processor plugin id
*
* @var string
*/
public $id;
/**
* The human-readable name of the processor plugin
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;
/**
* The processor description.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $description;
/**
* Class used to retrieve derivative definitions of the url processor.
*
* @var string
*/
public $derivative = '';
/**
* The stages this processor will run in, along with their default weights.
*
* This is represented as an associative array, mapping one or more of the
* stage identifiers to the default weight for that stage. For the available
* stages, see
* \Drupal\facetapi\Processor\ProcessorPluginManager::getProcessingStages().
*
* @var int[]
*/
public $stages;
}
......@@ -43,6 +43,7 @@ use Drupal\facetapi\Result\ResultInterface;
* "facet_source",
* "widget",
* "widget_configs",
* "processor_configs",
* },
* links = {
* "canonical" = "/admin/config/search/facet-api",
......@@ -149,6 +150,13 @@ class Facet extends ConfigEntityBase implements FacetInterface {
*/
protected $facetSourcePlugins;
/**
* An array containing all processors and their configuration.
*
* @var array
*/
protected $processor_configs;
/**
* {@inheritdoc}
*/
......@@ -379,5 +387,18 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return $this->path;
}
/**
* {@inheritdoc}
*/
public function getProcessorConfigs() {
return $this->processor_configs;
}
/**
* {@inheritdoc}
*/
public function setProcessorConfigs($processor_config = []) {
$this->processor_configs = $processor_config;
}
}
......@@ -197,4 +197,18 @@ interface FacetInterface extends ConfigEntityInterface {
*/
public function getPath();
/**
* Returns an array of processors with their configuration.
*
* @return array
*/
public function getProcessorConfigs();
/**
* Sets the processors with their config.
*
* @param array $processor_config
*/
public function setProcessorConfigs($processor_config = []);
}
......@@ -10,15 +10,18 @@ namespace Drupal\facetapi\FacetManager;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\facetapi\FacetApiException;
use Drupal\facetapi\FacetInterface;
use Drupal\facetapi\FacetSource\FacetSourcePluginManager;
use Drupal\facetapi\Processor\BuildProcessorInterface;
use Drupal\facetapi\Processor\PreQueryProcessorInterface;
use Drupal\facetapi\Processor\ProcessorInterface;
use Drupal\facetapi\Processor\ProcessorPluginManager;
use Drupal\facetapi\Processor\UrlProcessorInterface;
use Drupal\facetapi\QueryType\QueryTypePluginManager;
use Drupal\facetapi\Result\Result;
use Drupal\facetapi\UrlProcessor\UrlProcessorInterface;
use Drupal\facetapi\UrlProcessor\UrlProcessorPluginManager;
use Drupal\facetapi\Widget\WidgetPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
use \Drupal\facetapi\Entity\Facet;
/**
......@@ -40,18 +43,18 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
protected $query_type_plugin_manager;
/**
* The url processor plugin manager.
* The facet source plugin manager.
*
* @var UrlProcessorPluginManager
* @var FacetSourcePluginManager
*/
protected $url_processor_plugin_manager;
protected $facet_source_manager;
/**
* The facet source plugin manager.
* The processor plugin manager.
*
* @var FacetSourcePluginManager
* @var \Drupal\facetapi\Processor\ProcessorPluginManager
*/
protected $facet_source_manager;
protected $processor_plugin_manager;
/**
* @var ModuleHandlerInterface
......@@ -138,18 +141,16 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
/** @var \Drupal\facetapi\QueryType\QueryTypePluginManager $query_type_plugin_manager */
$query_type_plugin_manager = $container->get('plugin.manager.facetapi.query_type');
// Insert the plugin manager for url processors.
/** @var UrlProcessorPluginManager $url_processor_plugin_manager */
$url_processor_plugin_manager = $container->get('plugin.manager.facetapi.url_processor');
/** @var \Drupal\facetapi\Widget\WidgetPluginManager $widget_plugin_manager */
$widget_plugin_manager = $container->get('plugin.manager.facetapi.widget');
/** @var \Drupal\facetapi\FacetManager\FacetSourcePluginManager $facet_source_plugin_manager */
/** @var \Drupal\facetapi\FacetSource\FacetSourcePluginManager $facet_source_plugin_manager */
$facet_source_plugin_manager = $container->get('plugin.manager.facetapi.facet_source');
$plugin = new static($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $url_processor_plugin_manager, $widget_plugin_manager, $facet_source_plugin_manager);
return $plugin;
/** @var \Drupal\facetapi\Processor\ProcessorPluginManager $processor_plugin_manager */
$processor_plugin_manager = $container->get('plugin.manager.facetapi.processor');
return new static($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $widget_plugin_manager, $facet_source_plugin_manager, $processor_plugin_manager);
}
/**
......@@ -175,17 +176,17 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
$plugin_id, $plugin_definition,
ModuleHandlerInterface $module_handler,
QueryTypePluginManager $query_type_plugin_manager,
UrlProcessorPluginManager $url_processor_plugin_manager,
WidgetPluginManager $widget_plugin_manager,
FacetSourcePluginManager $facet_source_manager
FacetSourcePluginManager $facet_source_manager,
ProcessorPluginManager $processor_plugin_manager
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->module_handler = $module_handler;
$this->query_type_plugin_manager = $query_type_plugin_manager;
$this->url_processor_plugin_manager = $url_processor_plugin_manager;
$this->widget_plugin_manager = $widget_plugin_manager;
$this->facet_source_manager = $facet_source_manager;
$this->processor_plugin_manager = $processor_plugin_manager;
// Immediately initialize the facets.
// This can be done directly because the only thing needed is
......@@ -331,9 +332,6 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
// First add the results to the facets.
$this->updateResults();
// Then update the urls
$this->updateResultUrls();
// Set the facets to be processed.
$this->processed = TRUE;
}
......@@ -342,17 +340,25 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
/**
* Initialize enabled facets.
*
* In this method the url processor is used
* to check for each facet what the active items are.
* In this method all pre-query processors get called and their contents are
* executed.
*/
protected function initFacets() {
if (empty($this->facets)) {
$this->facets = $this->getEnabledFacets();
foreach ($this->facets as $facet) {
/** @var UrlProcessorInterface $url_processor */
$url_processor_name = $facet->getUrlProcessorName();
$url_processor = $this->url_processor_plugin_manager->createInstance($url_processor_name);
$url_processor->processFacet($facet);
foreach ($facet->getProcessorConfigs() as $processor_configuration) {
$processor_definition = $this->processor_plugin_manager->getDefinition($processor_configuration['processor_id']);
if (is_array($processor_definition['stages']) && array_key_exists(ProcessorInterface::STAGE_PRE_QUERY, $processor_definition['stages'])) {
/** @var PreQueryProcessorInterface $pre_query_processor */
$pre_query_processor = $this->processor_plugin_manager->createInstance($processor_configuration['processor_id']);
if (!$pre_query_processor instanceof PreQueryProcessorInterface) {
throw new FacetApiException($this->t("The processor @processor has a pre_query definition but doesn't implement the required PreQueryProcessorInterface interface", ['@processor' => $processor_configuration['processor_id']]));
}
$pre_query_processor->preQuery($facet);
}
}
}
}
}
......@@ -373,15 +379,36 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
$this->searcher_id = $facet->getFacetSource();
// For clarity, process facets is called each build.
// The first facet therefor will trigger the processing.
// Note that processing is done only once, so repeatedly
// calling this method will not trigger the processing more than once.
// Furthermore: don't add any processing after this method call!
// All processing should be done in the processFacets method.
// The first facet therefor will trigger the processing. Note that
// processing is done only once, so repeatedly calling this method will not
// trigger the processing more than once.
// Furthermore: don't add any processing after this method call! All
// processing should be done in the processFacets method.
//
// After the processFacets is finished, all information for rendering
// is added to the facet.
$this->processFacets();
// Get the current results from the facets and let all processors that
// trigger on the build step do their build processing.
// @see \Drupal\facetapi\Processor\BuildProcessorInterface
// @see \Drupal\facetapi\Processor\WidgetOrderProcessorInterface
$results = $facet->getResults();
foreach ($facet->getProcessorConfigs() as $processor_configuration) {
$processor_definition = $this->processor_plugin_manager->getDefinition($processor_configuration['processor_id']);
if (is_array($processor_definition['stages']) && array_key_exists(ProcessorInterface::STAGE_BUILD, $processor_definition['stages'])) {
/** @var BuildProcessorInterface $build_processor */
$build_processor = $this->processor_plugin_manager->createInstance($processor_configuration['processor_id']);
if (!$build_processor instanceof BuildProcessorInterface) {
throw new FacetApiException($this->t("The processor @processor has a build definition but doesn't implement the required BuildProcessorInterface interface", ['@processor' => $processor_configuration['processor_id']]));
}
$results = $build_processor->build($facet, $results);
}
}
$facet->setResults($results);
// Let the widget plugin render the facet.
/** @var \Drupal\facetapi\Widget\WidgetInterface $widget */
$widget = $this->widget_plugin_manager->createInstance($facet->getWidget());
......@@ -391,14 +418,4 @@ abstract class FacetManagerPluginBase extends PluginBase implements FacetManager
}
abstract public function updateResults();
protected function updateResultUrls() {
// Create the urls for the facets using the url processor.
foreach ($this->facets as $facet) {
/** @var UrlProcessorInterface $url_processor */
$url_processor_name = $facet->getUrlProcessorName();
$url_processor = $this->url_processor_plugin_manager->createInstance($url_processor_name);
$url_processor->addUriToResults($facet);
}
}
}
......@@ -14,6 +14,8 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\facetapi\FacetInterface;
use Drupal\facetapi\FacetApiException;
use Drupal\facetapi\FacetSource\FacetSourcePluginManager;
use Drupal\facetapi\Processor\ProcessorInterface;
use Drupal\facetapi\Processor\ProcessorPluginManager;
use Drupal\facetapi\Widget\WidgetPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -43,6 +45,13 @@ class FacetForm extends EntityForm {
*/
protected $facetSourcePluginManager;
/**
* The plugin manager for processors.
*
* @var \Drupal\facetapi\Processor\ProcessorPluginManager
*/
protected $processorPluginManager;
/**
* @var array
*/
......@@ -57,11 +66,14 @@ class FacetForm extends EntityForm {
* The plugin manager for widgets.
* @param \Drupal\facetapi\FacetSource\FacetSourcePluginManager $facetSourcePluginManager
* The plugin manager for facet sources.
* @param \Drupal\facetapi\Processor\ProcessorPluginManager $processorPluginManager
* The plugin manager for processors.
*/
public function __construct(EntityManagerInterface $entity_manager, WidgetPluginManager $widgetPluginManager, FacetSourcePluginManager $facetSourcePluginManager) {
public function __construct(EntityManagerInterface $entity_manager, WidgetPluginManager $widgetPluginManager, FacetSourcePluginManager $facetSourcePluginManager, ProcessorPluginManager $processorPluginManager) {
$this->facetStorage = $entity_manager->getStorage('facetapi_facet');
$this->widgetPluginManager = $widgetPluginManager;
$this->facetSourcePluginManager = $facetSourcePluginManager;
$this->processorPluginManager = $processorPluginManager;
}
/**
......@@ -77,7 +89,10 @@ class FacetForm extends EntityForm {
/** @var \Drupal\facetapi\FacetSource\FacetSourcePluginManager $facet_source_plugin_manager */
$facet_source_plugin_manager = $container->get('plugin.manager.facetapi.facet_source');
return new static($entity_manager, $widget_plugin_manager, $facet_source_plugin_manager);
/** @var \Drupal\facetapi\Processor\ProcessorPluginManager $processor_plugin_manager */
$processor_plugin_manager = $container->get('plugin.manager.facetapi.processor');
return new static($entity_manager, $widget_plugin_manager, $facet_source_plugin_manager, $processor_plugin_manager);
}
/**
......@@ -110,6 +125,17 @@ class FacetForm extends EntityForm {
return $this->facetSourcePluginManager ?: \Drupal::service('plugin.manager.facetapi.facet_source');
}
/**
* Returns the processor plugin manager.
*
* @return \Drupal\facetapi\Processor\ProcessorPluginManager
* The processor plugin manager.
*/
protected function getProcessorPluginManager() {
return $this->processorPluginManager ?: \Drupal::service('plugin.manager.facetapi.processor');
}
/**
* {@inheritdoc}
*/
......@@ -243,6 +269,34 @@ class FacetForm extends EntityForm {
];
$this->buildWidgetConfigForm($form, $form_state, $facet);
$form['processor_configs'] = [
'#type' => 'details',
'#title' => $this->t('Processors'),
'#tree' => TRUE,
'#open' => TRUE,
];
foreach ($this->getProcessorPluginManager()->getDefinitions() as $id => $definition) {
$form['processor_configs'][$id] = [
'#type' => 'details',
'#title' => $this->t('Processor: %id', ['%id' => $id]),
'#open' => TRUE,
];
$form['processor_configs'][$id]['processor_id'] = [
'#title' => 'id',
'#type' => 'hidden',
'#value' => $id
];
$form['processor_configs'][$id]['settings'] = [
'#type' => 'container'
];
/** @var ProcessorInterface $build_processor */
$build_processor = $this->getProcessorPluginManager()->createInstance($id);
$form['processor_configs'][$id]['settings'] = $build_processor->buildConfigurationForm($form, $form_state, $facet);
}
$form['status'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enabled'),
......
......@@ -9,6 +9,7 @@ use Drupal\facetapi\FacetManager\FacetManagerPluginBase;
use Drupal\facetapi\FacetInterface;
use Drupal\facetapi\FacetSource\FacetSourceInterface;
use Drupal\facetapi\FacetSource\FacetSourcePluginManager;
use Drupal\facetapi\Processor\ProcessorPluginManager;
use Drupal\facetapi\QueryType\QueryTypePluginManager;
use Drupal\facetapi\UrlProcessor\UrlProcessorPluginManager;
use Drupal\facetapi\Widget\WidgetPluginManager;
......@@ -49,18 +50,16 @@ class DefaultFacetManager extends FacetManagerPluginBase {
/** @var \Drupal\search_api\Query\ResultsCacheInterface $results_cache */
$results_cache = $container->get('search_api.results_static_cache');
// Insert the plugin manager for url processors.
/** @var UrlProcessorPluginManager $url_processor_plugin_manager */
$url_processor_plugin_manager = $container->get('plugin.manager.facetapi.url_processor');
/** @var \Drupal\facetapi\Widget\WidgetPluginManager $widget_plugin_manager */
$widget_plugin_manager = $container->get('plugin.manager.facetapi.widget');
/** @var FacetSourcePluginManager $facet_plugin_manager */
$facet_plugin_manager = $container->get('plugin.manager.facetapi.facet_source');
/** @var \Drupal\facetapi\Processor\ProcessorPluginManager $processor_plugin_manager */
$processor_plugin_manager = $container->get('plugin.manager.facetapi.processor');
return new static($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $results_cache, $url_processor_plugin_manager, $widget_plugin_manager, $facet_plugin_manager);
return new static($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $results_cache, $widget_plugin_manager, $facet_plugin_manager, $processor_plugin_manager);
}
public function __construct(
......@@ -69,12 +68,12 @@ class DefaultFacetManager extends FacetManagerPluginBase {
ModuleHandlerInterface $module_handler,
QueryTypePluginManager $query_type_plugin_manager,
ResultsCacheInterface $results_cache,
UrlProcessorPluginManager $url_processor_plugin_manager,
WidgetPluginManager $widget_plugin_manager,
FacetSourcePluginManager $facet_source_manager
FacetSourcePluginManager $facet_source_manager,
ProcessorPluginManager $processor_plugin_manager
) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $url_processor_plugin_manager, $widget_plugin_manager, $facet_source_manager);
parent::__construct($configuration, $plugin_id, $plugin_definition, $module_handler, $query_type_plugin_manager, $widget_plugin_manager, $facet_source_manager, $processor_plugin_manager);
$this->searchResultsCache = $results_cache;
}
......
<?php
namespace Drupal\facetapi\Plugin\facetapi\processor;
use Drupal\facetapi\Processor\WidgetOrderPluginBase;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
/**
* @FacetApiProcessor(
* id = "count_widget_order",
* label = @Translation("Sort by count"),
* description = @Translation("Sorts the widget results by count."),
* stages = {
* "build" = 50
* }
* )
*/
class CountWidgetOrderProcessor extends WidgetOrderPluginBase implements WidgetOrderProcessorInterface {
/**
* {@inheritdoc}
*/
public function sortResults(array $results, $order = 'ASC') {
if ($order === 'ASC') {
usort($results, 'self::sortCountAsc');
}
else {
usort($results, 'self::sortCountDesc');
}
return $results;
}
protected static function sortCountAsc(Result $a, Result $b) {
if ($a->getCount() == $b->getCount()) {
return 0;
}
return ($a->getCount() < $b->getCount()) ? -1 : 1;
}
protected static function sortCountDesc(Result $a, Result $b) {
if ($a->getCount() == $b->getCount()) {
return 0;
}
return ($a->getCount() > $b->getCount()) ? -1 : 1;
}
}
......@@ -5,61 +5,68 @@
* Contains Drupal\facetapi\Plugin\facetapi\url_processor\UrlProcessorQueryString
*/
namespace Drupal\facetapi\Plugin\facetapi\url_processor;
namespace Drupal\facetapi\Plugin\facetapi\processor;
use Drupal\Core\Url;
use Drupal\facetapi\FacetInterface;
use Drupal\facetapi\UrlProcessor\UrlProcessorPluginBase;
use Drupal\facetapi\Processor\UrlProcessorPluginBase;
use Drupal\facetapi\Result\Result;
use Symfony\Component\HttpFoundation\Request;
/**
* @FacetApiUrlProcessor(
* @FacetApiProcessor(
* id = "query_string",
* label = @Translation("Query string url processor"),
* description = @Translation("Most simple url processor which uses the query sting."),
* stages = {
* "pre_query" = 50,
* "build" = 15,
* }
* )
*
* Class UrlProcessorQueryString
* @package Drupal\facetapi\Plugin\facetapi\url_processor
*/
class UrlProcessorQueryString extends UrlProcessorPluginBase{
class QueryStringUrlProcessor extends UrlProcessorPluginBase {
/**
* A string that separates the filters in the query string
*/
const SEPARATOR = ':';
protected $active_filters = array();
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
Request $request
) {
parent::__construct($configuration, $plugin_id, $plugin_definition,
$request);
/**
* @var array
* An array containing the active filters
*/
protected $active_filters = [];
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $request);
$this->initializeActiveFilters();
}
public function addUriToResults(FacetInterface $facet) {
/**
* {@inheritdoc}
*/
public function build(FacetInterface $facet, array $results) {
// Create links for all the values.
// First get the current list of get parameters.
$get_params = $this->request->query;
$results = $facet->getResults();
// No results are found for this facet, so dont try to create urls.
// No results are found for this facet, so don't try to create urls.
if (is_null($results)) {
return;
return [];
}
foreach ($results as $result) {
$return_results = [];
/** @var Result $result */
foreach ($results as &$result) {
$filter_string = $facet->getFieldAlias() . ':' . $result->getValue();
$result_get_params = clone $get_params;
$filter_params = $result_get_params->get($this->filter_key, [], TRUE);
// If the value is active, remove the filter string from the
// parameters.
// If the value is active, remove the filter string from the parameters.
if ($result->isActive()) {
foreach ($filter_params as $key => $filter_param) {
if ($filter_param == $filter_string) {
......@@ -79,12 +86,18 @@ class UrlProcessorQueryString extends UrlProcessorPluginBase{
}
$url = Url::createFromRequest($request);
$url->setOption('query', $result_get_params->all());
$result->setUrl($url);
}
return $results;
}
public function processFacet(FacetInterface $facet) {
/**
* {@inheritdoc}
*/
public function preQuery(FacetInterface $facet) {
// Get the filterkey of the facet.
if (isset($this->active_filters[$facet->getFieldAlias()])) {
foreach ($this->active_filters[$facet->getFieldAlias()] as $value) {
......@@ -96,11 +109,9 @@ class UrlProcessorQueryString extends UrlProcessorPluginBase{
/**
* Initialize the active filters.
*
* Get all the filters that are active.
* This method only get's all the filters,
* but doesn't assign them to facets.
* In the processFacet method the active values
* for a specific facet are added to the facet.
* Get all the filters that are active. This method only get's all the
* filters but doesn't assign them to facets. In the processFacet method the
* active values for a specific facet are added to the facet.
*/
protected function initializeActiveFilters() {
$url_parameters = $this->request->query;
......
......@@ -32,7 +32,7 @@ class LinksWidget implements WidgetInterface {
$build = array();
/** @var Result[] $results */
$results = $facet->getResults();
if (! empty ($results)) {
if (!empty($results)) {
$items = array();
foreach ($results as $result) {
if ($result->getCount()) {
......
<?php
/**
* @file
* Contains \Drupal\facetapi\Processor\BuildProcessorInterface.
*/
namespace Drupal\facetapi\Processor;
use Drupal\facetapi\FacetInterface;
/**
* Processor runs before the renderable array is created.
*/
interface BuildProcessorInterface extends ProcessorInterface {
/**
* Processor runs before the renderable array is created.