Skip to content
......@@ -108,15 +108,11 @@ class DefaultFacetManager {
protected $facetSourceId;
/**
* Set the search id.
* The entity storage for facets.
*
* @param string $facet_source_id
* The id of the facet source.
* @var \Drupal\Core\Entity\EntityStorageInterface|object
*/
public function setFacetSourceId($facet_source_id) {
$this->facetSourceId = $facet_source_id;
}
protected $facetStorage;
/**
* Constructs a new instance of the DefaultFacetManager.
*
......@@ -136,13 +132,23 @@ class DefaultFacetManager {
$this->widgetPluginManager = $widget_plugin_manager;
$this->facetSourcePluginManager = $facet_source_manager;
$this->processorPluginManager = $processor_plugin_manager;
$this->facet_storage = $entity_type_manager->getStorage('facets_facet');
$this->facetStorage = $entity_type_manager->getStorage('facets_facet');
// Immediately initialize the facets. This can be done directly because the
// only thing needed is the url.
$this->initFacets();
}
/**
* Sets the search id.
*
* @param string $facet_source_id
* The id of the facet source.
*/
public function setFacetSourceId($facet_source_id) {
$this->facetSourceId = $facet_source_id;
}
/**
* Allows the backend to add facet queries to its native query object.
*
......@@ -178,11 +184,11 @@ class DefaultFacetManager {
* An array of enabled facets.
*/
public function getEnabledFacets() {
return $this->facet_storage->loadMultiple();
return $this->facetStorage->loadMultiple();
}
/**
* Get the ID of the facet source.
* Returns the ID of the facet source.
*
* @return string
* The id of the facet source.
......@@ -209,7 +215,7 @@ class DefaultFacetManager {
}
/**
* Initialize enabled facets.
* Initializes enabled facets.
*
* In this method all pre-query processors get called and their contents are
* executed.
......@@ -219,23 +225,20 @@ class DefaultFacetManager {
$this->facets = $this->getEnabledFacets();
foreach ($this->facets as $facet) {
foreach ($facet->getProcessors() as $processor) {
$processor_definition = $processor->getPluginDefinition();
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->processorPluginManager->createInstance($processor->getPluginDefinition()['id'], ['facet' => $facet]);
if (!$pre_query_processor instanceof PreQueryProcessorInterface) {
throw new InvalidProcessorException(new FormattableMarkup("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);
foreach ($facet->getProcessorsByStage(ProcessorInterface::STAGE_PRE_QUERY) as $processor) {
/** @var PreQueryProcessorInterface $pre_query_processor */
$pre_query_processor = $this->processorPluginManager->createInstance($processor->getPluginDefinition()['id'], ['facet' => $facet]);
if (!$pre_query_processor instanceof PreQueryProcessorInterface) {
throw new InvalidProcessorException(new FormattableMarkup("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);
}
}
}
}
/**
* Build a facet and returns it's render array.
* Builds a facet and returns it as a renderable array.
*
* This method delegates to the relevant plugins to render a facet, it calls
* out to a widget plugin to do the actual rendering when results are found.
......@@ -283,16 +286,13 @@ class DefaultFacetManager {
// @see \Drupal\facets\Processor\WidgetOrderProcessorInterface.
$results = $facet->getResults();
foreach ($facet->getProcessors() as $processor) {
$processor_definition = $this->processorPluginManager->getDefinition($processor->getPluginDefinition()['id']);
if (is_array($processor_definition['stages']) && array_key_exists(ProcessorInterface::STAGE_BUILD, $processor_definition['stages'])) {
/** @var BuildProcessorInterface $build_processor */
$build_processor = $this->processorPluginManager->createInstance($processor->getPluginDefinition()['id'], ['facet' => $facet]);
if (!$build_processor instanceof BuildProcessorInterface) {
throw new InvalidProcessorException(new FormattableMarkup("The processor @processor has a build definition but doesn't implement the required BuildProcessorInterface interface", ['@processor' => $processor['processor_id']]));
}
$results = $build_processor->build($facet, $results);
foreach ($facet->getProcessorsByStage(ProcessorInterface::STAGE_BUILD) as $processor) {
/** @var BuildProcessorInterface $build_processor */
$build_processor = $this->processorPluginManager->createInstance($processor->getPluginDefinition()['id'], ['facet' => $facet]);
if (!$build_processor instanceof BuildProcessorInterface) {
throw new InvalidProcessorException(new FormattableMarkup("The processor @processor has a build definition but doesn't implement the required BuildProcessorInterface interface", ['@processor' => $processor['processor_id']]));
}
$results = $build_processor->build($facet, $results);
}
$facet->setResults($results);
......@@ -336,6 +336,7 @@ class DefaultFacetManager {
*
* @param string $facet_id
* The id of the facet.
*
* @return \Drupal\facets\FacetInterface|NULL
* The updated facet if it exists, NULL otherwise.
*/
......
......@@ -82,7 +82,6 @@ abstract class FacetSourceDeriverBase implements ContainerDeriverInterface {
return isset($derivatives[$derivative_id]) ? $derivatives[$derivative_id] : NULL;
}
/**
* Compares two plugin definitions according to their labels.
*
......
......@@ -7,10 +7,8 @@
namespace Drupal\facets\FacetSource;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\facets\Exception\InvalidProcessorException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Facets\FacetInterface;
use Drupal\Core\Form\FormStateInterface;
......
......@@ -22,7 +22,7 @@ use Drupal\facets\FacetInterface;
interface FacetSourcePluginInterface extends PluginFormInterface {
/**
* Fill in facet data in to the configured facets.
* Fills the facet entities with results from the facet source.
*
* @param \Drupal\facets\FacetInterface[] $facets
* The configured facets.
......@@ -30,7 +30,7 @@ interface FacetSourcePluginInterface extends PluginFormInterface {
public function fillFacetsWithResults($facets);
/**
* Get the allowed query types for a given facet for the facet source.
* Returns the allowed query types for a given facet for the facet source.
*
* @param \Drupal\facets\FacetInterface $facet
* The facet we should get query types for.
......@@ -86,7 +86,7 @@ interface FacetSourcePluginInterface extends PluginFormInterface {
public function setSearchKeys($keys);
/**
* Gets the search keys, or query text, submitted by the user.
* Returns the search keys, or query text, submitted by the user.
*
* @return string
* The search keys, or query text, submitted by the user.
......
......@@ -21,15 +21,7 @@ use Drupal\Core\Plugin\DefaultPluginManager;
class FacetSourcePluginManager extends DefaultPluginManager {
/**
* Constructs a FacetSourcePluginManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/facets/facet_source', $namespaces, $module_handler, 'Drupal\facets\FacetSource\FacetSourcePluginInterface', 'Drupal\facets\Annotation\FacetsFacetSource');
......
......@@ -23,7 +23,7 @@ interface FacetSourceInterface extends ConfigEntityInterface {
public function getName();
/**
* Gets the filter key for this facet source.
* Returns the filter key for this facet source.
*
* @return string
* The filter key.
......@@ -39,7 +39,7 @@ interface FacetSourceInterface extends ConfigEntityInterface {
public function setFilterKey($filter_key);
/**
* Set the processor name to be used.
* Sets the processor name to be used.
*
* @param string $processor_name
* Plugin name of the url processor.
......
......@@ -224,7 +224,7 @@ class FacetDisplayForm extends EntityForm {
$form['facet_settings'][$processor_id]['status'] = array(
'#type' => 'checkbox',
'#title' => (string) $processor->getPluginDefinition()['label'],
'#default_value' => $processor->isLocked() || !empty($processor->configuration['enabled']),
'#default_value' => $processor->isLocked() || !empty($enabled_processors[$processor_id]),
'#description' => $processor->getDescription(),
'#attributes' => array(
'class' => array(
......@@ -326,7 +326,6 @@ class FacetDisplayForm extends EntityForm {
'#default_value' => $facet->getOnlyVisibleWhenFacetSourceIsVisible(),
];
// Behavior for empty facets.
$empty_behavior_config = $facet->getEmptyBehavior();
$form['facet_settings']['empty_behavior'] = [
'#type' => 'radios',
......@@ -352,7 +351,6 @@ class FacetDisplayForm extends EntityForm {
'#default_value' => isset($empty_behavior_config['text_format']) ? $empty_behavior_config['text'] : '',
];
// Query operator.
$form['facet_settings']['query_operator'] = [
'#type' => 'radios',
'#title' => $this->t('Operator'),
......@@ -361,6 +359,13 @@ class FacetDisplayForm extends EntityForm {
'#default_value' => $facet->getQueryOperator(),
];
$form['facet_settings']['exclude'] = [
'#type' => 'checkbox',
'#title' => $this->t('Exclude'),
'#description' => $this->t('Make the search exclude selected facets, instead of restricting it to them.'),
'#default_value' => $facet->getExclude(),
];
$form['weights'] = array(
'#type' => 'details',
'#title' => t('Advanced settings'),
......@@ -393,6 +398,8 @@ class FacetDisplayForm extends EntityForm {
);
}
$processor_settings = $facet->getProcessorConfigs();
// Fill in the containers previously created with the processors that are
// enabled on the facet.
foreach ($processors_by_stage as $stage => $processors) {
......@@ -498,9 +505,8 @@ class FacetDisplayForm extends EntityForm {
'weights' => array(),
'settings' => array(),
);
$processor_values = $values[$form_container_key][$processor_id];
if (!empty($processor_values['weights'])) {
$new_settings['weights'] = $processor_values['weights'];
if (!empty($values['processors'][$processor_id]['weights'])) {
$new_settings['weights'] = $values['processors'][$processor_id]['weights'];
}
if (isset($form[$form_container_key][$processor_id]['settings'])) {
$processor_form_state = new SubFormState(
......@@ -536,14 +542,16 @@ class FacetDisplayForm extends EntityForm {
}
$facet->setEmptyBehavior($empty_behavior_config);
$facet->setOption('query_operator', $form_state->getValue(['facet_settings', 'query_operator']));
$facet->setQueryOperator($form_state->getValue(['facet_settings', 'query_operator']));
$facet->setExclude($form_state->getValue(['facet_settings', 'exclude']));
$facet->save();
drupal_set_message(t('Facet %name has been updated.', ['%name' => $facet->getName()]));
}
/**
* Form submission handler for the widget subform.
* Handles form submissions for the widget subform.
*/
public function submitAjaxWidgetConfigForm($form, FormStateInterface $form_state) {
$form_state->setRebuild();
......
......@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class FacetForm extends EntityForm {
/**
* The facet storage controller.
* The facet storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
......@@ -74,22 +74,6 @@ class FacetForm extends EntityForm {
return new static($entity_type_manager, $facet_source_plugin_manager, $processor_plugin_manager);
}
/**
* Gets the form entity.
*
* The form entity which has been used for populating form element defaults.
* This method is defined on the \Drupal\Core\Entity\EntityFormInterface and
* has the same contents there, we only extend to add the correct return type,
* this makes IDE's smarter about the other places where we use
* $this->getEntity().
*
* @return \Drupal\facets\FacetInterface
* The current form facet entity.
*/
public function getEntity() {
return $this->entity;
}
/**
* Retrieves the facet storage controller.
*
......@@ -174,11 +158,15 @@ class FacetForm extends EntityForm {
];
$form['url_alias'] = [
'#type' => 'textfield',
'#type' => 'machine_name',
'#title' => $this->t('The name of the facet for usage in URLs'),
'#default_value' => $facet->getUrlAlias(),
'#maxlength' => 50,
'#required' => TRUE,
'#machine_name' => [
'exists' => [$this->getFacetStorage(), 'load'],
'source' => ['name'],
],
];
$facet_sources = [];
......@@ -230,9 +218,10 @@ class FacetForm extends EntityForm {
}
/**
* Form submission handler for the facet source subform.
* Handles form submissions for the facet source subform.
*/
public function submitAjaxFacetSourceConfigForm($form, FormStateInterface $form_state) {
$form_state->setValue('id', NULL);
$form_state->setRebuild();
}
......@@ -271,6 +260,13 @@ class FacetForm extends EntityForm {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$facet_source_id = $form_state->getValue('facet_source_id');
if (!is_null($facet_source_id) && $facet_source_id !== '') {
/** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */
$facet_source = $this->getFacetSourcePluginManager()->createInstance($facet_source_id, ['facet' => $this->getEntity()]);
$facet_source->validateConfigurationForm($form, $form_state);
}
}
/**
......
......@@ -44,6 +44,11 @@ class FacetSourceEditForm extends EntityForm {
/**
* Constructs a FacetSourceEditForm.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\facets\UrlProcessor\UrlProcessorPluginManager $url_processor_plugin_manager
* The url processor plugin manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, UrlProcessorPluginManager $url_processor_plugin_manager) {
$facet_source_storage = $entity_type_manager->getStorage('facets_facet_source');
......@@ -61,7 +66,6 @@ class FacetSourceEditForm extends EntityForm {
$this->setEntity($facet_source);
}
else {
// We didn't have a facet source config entity yet for this facet source
// plugin, so we create it on the fly.
$facet_source = new FacetSource(
......@@ -93,8 +97,7 @@ class FacetSourceEditForm extends EntityForm {
/** @var \Drupal\facets\FacetSourceInterface $facet_source */
$facet_source = $this->getEntity();
// Filter key setting.
$form['filterKey'] = [
$form['filter_key'] = [
'#type' => 'textfield',
'#title' => $this->t('Filter key'),
'#size' => 20,
......@@ -112,13 +115,13 @@ class FacetSourceEditForm extends EntityForm {
$url_processors[$definition['id']] = $definition['label'];
$url_processors_description[] = $definition['description'];
}
$form['urlProcessor'] = [
$form['url_processor'] = [
'#type' => 'radios',
'#title' => $this->t('URL Processor'),
'#options' => $url_processors,
'#default_value' => $facet_source->getUrlProcessorName(),
'#description' => $this->t(
'The URL Processor defines the url structure used for this facet source.') . '<br />- ' . implode('<br>- ', $url_processors_description),
'The URL Processor defines the url structure used for this facet source.') . '<br />- ' . implode('<br>- ', $url_processors_description),
];
// The parent's form build method will add a save button.
......
......@@ -49,7 +49,7 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
* The plugin implementation definition.
* @param \Drupal\facets\FacetManager\DefaultFacetManager $facet_manager
* The facet manager.
* @param \Drupal\Core\Entity\EntityStorageInterface
* @param \Drupal\Core\Entity\EntityStorageInterface $facet_storage
* The entity storage used for facets.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, DefaultFacetManager $facet_manager, EntityStorageInterface $facet_storage) {
......@@ -128,9 +128,9 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
// impossible to improve this significantly.
//
// Note: when using Drupal core's Search module instead of the contributed
// Search API module, the above limitations do not apply, but for now
// it is not considered worth the effort to optimize this just for
// Drupal core's Search.
// Search API module, the above limitations do not apply, but for now it is
// not considered worth the effort to optimize this just for Drupal core's
// Search.
return 0;
}
......
......@@ -37,8 +37,8 @@ class FacetBlockDeriver implements ContainerDeriverInterface {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
$deriver = new static;
$deriver->facetStorage = \Drupal::getContainer()->get('entity_type.manager')->getStorage('facets_facet');
$deriver = new static($container, $base_plugin_id);
$deriver->facetStorage = $container->get('entity_type.manager')->getStorage('facets_facet');
return $deriver;
}
......
......@@ -80,7 +80,7 @@ class OtherFacet extends ConditionPluginBase implements ContainerFactoryPluginIn
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public function __construct(EntityStorageInterface $entity_storage, BlockManager $block_manager, AccountProxyInterface $current_user, DefaultFacetManager $facet_manager,array $configuration, $plugin_id, $plugin_definition) {
public function __construct(EntityStorageInterface $entity_storage, BlockManager $block_manager, AccountProxyInterface $current_user, DefaultFacetManager $facet_manager, array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->facetStorage = $entity_storage;
$this->blockManager = $block_manager;
......
......@@ -83,7 +83,7 @@ abstract class SearchApiBaseFacetSource extends FacetSourcePluginBase {
*/
public function getFields() {
$indexed_fields = [];
$fields = $this->index->getFields(TRUE);
$fields = $this->index->getFields();
foreach ($fields as $field) {
$indexed_fields[$field->getFieldIdentifier()] = $field->getLabel();
}
......@@ -98,16 +98,17 @@ abstract class SearchApiBaseFacetSource extends FacetSourcePluginBase {
// identifier.
$field_id = $facet->getFieldIdentifier();
// Get the Search API Server.
$server = $this->index->getServer();
$server = $this->index->getServerInstance();
// Get the Search API Backend.
$backend = $server->getBackend();
$fields = $this->index->getFields(TRUE);
$fields = $this->index->getFields();
foreach ($fields as $field) {
if ($field->getFieldIdentifier() == $field_id) {
return $this->getQueryTypesForDataType($backend, $field->getType());
}
}
throw new InvalidQueryTypeException($this->t("No available query types were found for facet @facet", ['@facet' => $facet->getName()]));
}
......
......@@ -17,7 +17,8 @@ use Drupal\facets\Processor\ProcessorPluginBase;
* The URL processor handler triggers the actual url processor.
*
* The URL processor handler allows managing the weight of the actual URL
* processor per Facet. This handler will trigger the actual
* processor per Facet. This handler will trigger the actual.
*
* @FacetsUrlProcessor, which can be configured on the Facet source.
*
* @FacetsProcessor(
......@@ -31,9 +32,13 @@ use Drupal\facets\Processor\ProcessorPluginBase;
* locked = true
* )
*/
class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorInterface, PreQueryProcessorInterface{
class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorInterface, PreQueryProcessorInterface {
/** @var \Drupal\facets\UrlProcessor\UrlProcessorInterface */
/**
* The actual url processor used for handing urls.
*
* @var \Drupal\facets\UrlProcessor\UrlProcessorInterface
*/
protected $processor;
/**
......@@ -55,7 +60,7 @@ class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorI
$url_processor_name = $fs->getUrlProcessorName();
$manager = \Drupal::getContainer()->get('plugin.manager.facets.url_processor');
$this->processor= $manager->createInstance($url_processor_name, ['facet' => $facet]);
$this->processor = $manager->createInstance($url_processor_name, ['facet' => $facet]);
}
/**
......
......@@ -29,7 +29,7 @@ use Drupal\facets\Result\Result;
class SearchApiString extends QueryTypePluginBase {
/**
* Holds the backend's native query object.
* The backend's native query object.
*
* @var \Drupal\search_api\Query\QueryInterface
*/
......@@ -47,6 +47,7 @@ class SearchApiString extends QueryTypePluginBase {
if (!empty($query)) {
$operator = $this->facet->getQueryOperator();
$field_identifier = $this->facet->getFieldIdentifier();
$exclude = $this->facet->getExclude();
// Copy the query object so we can do an unfiltered query. We need to have
// this unfiltered results to make sure that the count of a facet is
......@@ -65,7 +66,6 @@ class SearchApiString extends QueryTypePluginBase {
->execute()
->getExtraData('search_api_facets');
// Set the options for the actual query.
$options = &$query->getOptions();
$options['search_api_facets'][$field_identifier] = array(
......@@ -82,7 +82,7 @@ class SearchApiString extends QueryTypePluginBase {
if (count($active_items)) {
$filter = $query->createConditionGroup($operator);
foreach ($active_items as $value) {
$filter->addCondition($this->facet->getFieldIdentifier(), $value);
$filter->addCondition($this->facet->getFieldIdentifier(), $value, $exclude ? '<>' : '=');
}
$query->addConditionGroup($filter);
}
......
......@@ -33,7 +33,7 @@ class QueryString extends UrlProcessorPluginBase {
*
* @var string
*/
protected $url_alias;
protected $urlAlias;
/**
* An array of active filters.
......@@ -55,21 +55,20 @@ class QueryString extends UrlProcessorPluginBase {
* {@inheritdoc}
*/
public function buildUrls(FacetInterface $facet, array $results) {
// Create links for all the values.
// First get the current list of get parameters.
$get_params = $this->request->query;
// Set the url alias from the the facet object.
$this->url_alias = $facet->getUrlAlias();
// No results are found for this facet, so don't try to create urls.
if (empty($results)) {
return [];
}
// First get the current list of get parameters.
$get_params = $this->request->query;
// Set the url alias from the the facet object.
$this->urlAlias = $facet->getUrlAlias();
/** @var \Drupal\facets\Result\ResultInterface $result */
foreach ($results as &$result) {
$filter_string = $this->url_alias . self::SEPARATOR . $result->getRawValue();
$filter_string = $this->urlAlias . self::SEPARATOR . $result->getRawValue();
$result_get_params = clone $get_params;
$filter_params = $result_get_params->get($this->filterKey, [], TRUE);
......@@ -105,18 +104,18 @@ class QueryString extends UrlProcessorPluginBase {
*/
public function setActiveItems(FacetInterface $facet) {
// Set the url alias from the the facet object.
$this->url_alias = $facet->getUrlAlias();
$this->urlAlias = $facet->getUrlAlias();
// Get the filter key of the facet.
if (isset($this->activeFilters[$this->url_alias])) {
foreach ($this->activeFilters[$this->url_alias] as $value) {
if (isset($this->activeFilters[$this->urlAlias])) {
foreach ($this->activeFilters[$this->urlAlias] as $value) {
$facet->setActiveItem(trim($value, '"'));
}
}
}
/**
* Initialize the active filters.
* Initializes 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
......
......@@ -99,7 +99,7 @@ class CheckboxWidget implements WidgetInterface, FormInterface {
$results = $facet->getResults();
$configuration = $facet->getWidgetConfigs();
$show_numbers = (bool) $configuration['show_numbers'];
$show_numbers = (bool) (isset($configuration['show_numbers']) ? $configuration['show_numbers'] : FALSE);
$form[$facet->getFieldAlias()] = [
'#type' => 'checkboxes',
'#title' => $facet->getName(),
......@@ -175,4 +175,5 @@ class CheckboxWidget implements WidgetInterface, FormInterface {
$link->setAbsolute();
$form_state->setResponse(new RedirectResponse($link->toString()));
}
}
......@@ -42,7 +42,7 @@ class LinksWidget implements WidgetInterface {
$items = [];
$configuration = $facet->getWidgetConfigs();
$show_numbers = (bool) $configuration['show_numbers'];
$show_numbers = empty($configuration['show_numbers']) ? FALSE : (bool) $configuration['show_numbers'];
foreach ($results as $result) {
// Get the link.
......@@ -68,9 +68,9 @@ class LinksWidget implements WidgetInterface {
'#cache' => [
'contexts' => [
'url.path',
'url.query_args'
]
]
'url.query_args',
],
],
];
return $build;
}
......
......@@ -16,7 +16,7 @@ use Drupal\facets\FacetInterface;
interface BuildProcessorInterface extends ProcessorInterface {
/**
* Processor runs before the renderable array is created.
* Runs before the renderable array is created.
*
* @param \Drupal\facets\FacetInterface $facet
* The facet being changed.
......
......@@ -14,7 +14,7 @@ namespace Drupal\facets\Processor;
interface PostQueryProcessorInterface extends ProcessorInterface {
/**
* Processor runs after the query was executed.
* Runs after the query was executed.
*
* Uses the query results and can alter those results, for example a
* ValueCallbackProcessor.
......