Skip to content
......@@ -2,24 +2,24 @@
/**
* @file
* Contains \Drupal\facetapi\Annotation\FacetApiFacet.
* Contains \Drupal\facets\Annotation\FacetsFacetSource.
*/
namespace Drupal\facetapi\Annotation;
namespace Drupal\facets\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facet API facet source annotation.
* Defines a Facets facet source annotation.
*
* @see \Drupal\facetapi\FacetSource\FacetSourcePluginManager
* @see \Drupal\facetapi\FacetSource\FacetSourceInterface
* @see \Drupal\facetapi\FacetSource\FacetSourcePluginBase
* @see \Drupal\facets\FacetSource\FacetSourcePluginManager
* @see \Drupal\facets\FacetSource\FacetSourcePluginInterface
* @see \Drupal\facets\FacetSource\FacetSourcePluginBase
* @see plugin_api
*
* @Annotation
*/
class FacetApiFacetSource extends Plugin {
class FacetsFacetSource extends Plugin {
/**
* The facet source plugin ID.
......@@ -29,7 +29,7 @@ class FacetApiFacetSource extends Plugin {
public $id;
/**
* The human-readable name of the facet soruce plugin.
* The human-readable name of the facet source plugin.
*
* @ingroup plugin_translatable
*
......
<?php
/**
* @file
* Contains \Drupal\facetapi\Annotation\FacetApiProcessor.
* Contains \Drupal\facets\Annotation\FacetsProcessor.
*/
namespace Drupal\facetapi\Annotation;
namespace Drupal\facets\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facet API Processor annotation.
* Defines a Facets Processor annotation.
*
* @see \Drupal\facetapi\Processor\ProcessorPluginManager
* @see \Drupal\facets\Processor\ProcessorPluginManager
* @see plugin_api
*
* @ingroup plugin_api
*
* @Annotation
*/
class FacetApiProcessor extends Plugin {
class FacetsProcessor extends Plugin {
/**
* The processor plugin id.
......@@ -58,7 +58,7 @@ class FacetApiProcessor extends Plugin {
* 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().
* \Drupal\facets\Processor\ProcessorPluginManager::getProcessingStages().
*
* @var int[]
*/
......
......@@ -2,24 +2,24 @@
/**
* @file
* Contains \Drupal\facetapi\Annotation\FacetApiQueryType.
* Contains \Drupal\facets\Annotation\FacetsQueryType.
*/
namespace Drupal\facetapi\Annotation;
namespace Drupal\facets\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facet API query type annotation.
* Defines a Facets query type annotation.
*
* @see \Drupal\facetapi\QueryType\QueryTypePluginManager
* @see \Drupal\facets\QueryType\QueryTypePluginManager
* @see plugin_api
*
* @ingroup plugin_api
*
* @Annotation
*/
class FacetApiQueryType extends Plugin {
class FacetsQueryType extends Plugin {
/**
* The query type plugin id.
......
<?php
/**
* @file
* Contains \Drupal\facets\Annotation\FacetsUrlProcessor.
*/
namespace Drupal\facets\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facets URL Processor annotation.
*
* @see \Drupal\facets\Processor\ProcessorPluginManager
* @see plugin_api
*
* @ingroup plugin_api
*
* @Annotation
*/
class FacetsUrlProcessor extends Plugin {
/**
* The URL processor plugin id.
*
* @var string
*/
public $id;
/**
* The human-readable name of the URL processor plugin.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;
/**
* The URL processor description.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $description;
}
......@@ -2,24 +2,24 @@
/**
* @file
* Contains \Drupal\facetapi\Annotation\FacetApiWidget.
* Contains \Drupal\facets\Annotation\FacetsWidget.
*/
namespace Drupal\facetapi\Annotation;
namespace Drupal\facets\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a Facet API Widget annotation.
* Defines a Facets Widget annotation.
*
* @see \Drupal\facetapi\Widget\WidgetPluginManager
* @see \Drupal\facets\Widget\WidgetPluginManager
* @see plugin_api
*
* @ingroup plugin_api
*
* @Annotation
*/
class FacetApiWidget extends Plugin {
class FacetsWidget extends Plugin {
/**
* The widget plugin id.
......
<?php
/**
* @file
* Contains \Drupal\facetapi\ContextProvider\FacetContextProvider.
*/
namespace Drupal\facetapi\ContextProvider;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* A provider for the core context system for facets.
*
* This provider is a provider for core's context system, it makes integration
* with blocks, panels and other layout systems easy.
*/
class FacetContextProvider implements ContextProviderInterface {
use StringTranslationTrait;
protected $facetStorage;
/**
* Create a new instance of the context provider.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->facetStorage = $entity_type_manager->getStorage('facetapi_facet');
}
/**
* {@inheritdoc}
*/
public function getRuntimeContexts(array $unqualified_context_ids = []) {
$ids = $this->facetStorage->getQuery()
->condition('uuid', $unqualified_context_ids, 'IN')
->execute();
$contexts = [];
foreach ($this->facetStorage->loadMultiple($ids) as $facet) {
$context = new Context(new ContextDefinition('entity:facetapi_facet'), $facet);
$contexts[$facet->uuid()] = $context;
}
return $contexts;
}
/**
* {@inheritdoc}
*/
public function getAvailableContexts() {
$facets = $this->facetStorage->loadMultiple();
$contexts = [];
/** @var \Drupal\facetapi\FacetInterface $facet */
foreach ($facets as $facet) {
$context = new Context(
new ContextDefinition('entity:facetapi_facet', $facet->label()),
$facet
);
$contexts[$facet->uuid()] = $context;
}
return $contexts;
}
}
......@@ -2,14 +2,14 @@
/**
* @file
* Contains \Drupal\facetapi\Controller\FacetController.
* Contains \Drupal\facets\Controller\FacetController.
*/
namespace Drupal\facetapi\Controller;
namespace Drupal\facets\Controller;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Controller\ControllerBase;
use Drupal\facetapi\FacetInterface;
use Drupal\facets\FacetInterface;
/**
* Provides route responses for facets.
......@@ -19,7 +19,7 @@ class FacetController extends ControllerBase {
/**
* Displays information about a search facet.
*
* @param \Drupal\facetapi\FacetInterface $facet
* @param \Drupal\facets\FacetInterface $facet
* The facet to display.
*
* @return array
......@@ -29,7 +29,7 @@ class FacetController extends ControllerBase {
// Build the search index information.
$render = array(
'view' => array(
'#theme' => 'facetapi_facet',
'#theme' => 'facets_facet',
'#facet' => $facet,
),
);
......@@ -43,28 +43,28 @@ class FacetController extends ControllerBase {
* The facet add form.
*/
public function addForm() {
$facet = \Drupal::service('entity_type.manager')->getStorage('facetapi_facet')->create();
$facet = \Drupal::service('entity_type.manager')->getStorage('facets_facet')->create();
return $this->entityFormBuilder()->getForm($facet, 'default');
}
/**
* Returns a form to edit a facet on a search api index.
*
* @param \Drupal\facetapi\FacetInterface $facetapi_facet
* Facet currently being edited
* @param \Drupal\facets\FacetInterface $facets_facet
* Facet currently being edited.
*
* @return array
* The facet edit form.
*/
public function editForm(FacetInterface $facetapi_facet) {
$facet = \Drupal::service('entity_type.manager')->getStorage('facetapi_facet')->load($facetapi_facet->id());
public function editForm(FacetInterface $facets_facet) {
$facet = \Drupal::service('entity_type.manager')->getStorage('facets_facet')->load($facets_facet->id());
return $this->entityFormBuilder()->getForm($facet, 'default');
}
/**
* Returns the page title for an facets's "View" tab.
*
* @param \Drupal\facetapi/FacetInterface $facet
* @param \Drupal\facets\FacetInterface $facet
* The facet that is displayed.
*
* @return string
......
<?php
/**
* @file
* Contains \Drupal\facets\Controller\FacetSourceController.
*/
namespace Drupal\facets\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Provides route responses for facet source configuration.
*/
class FacetSourceController extends ControllerBase {
/**
* Configuration for the facet source.
*
* @param string $source_id
* The plugin id.
*
* @return array
* A renderable array containing the form.
*/
public function facetSourceConfigForm($source_id) {
// Returns the render array of the FacetSourceConfigForm.
return $this->formBuilder()->getForm('\Drupal\facets\Form\FacetSourceEditForm');
}
}
This diff is collapsed.
<?php
/**
* @file
* Contains \Drupal\facets\Entity\FacetSource.
*/
namespace Drupal\facets\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\facets\FacetSourceInterface;
/**
* Defines the facet source configuration entity.
*
* @ConfigEntityType(
* id = "facets_facet_source",
* label = @Translation("Facet source"),
* handlers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage",
* "list_builder" = "Drupal\facets\FacetListBuilder",
* "form" = {
* "default" = "Drupal\facets\Form\FacetSourceEditForm",
* "edit" = "Drupal\facets\Form\FacetSourceEditForm",
* "display" = "Drupal\facets\Form\FacetSourceDisplayForm",
* "delete" = "Drupal\facets\Form\FacetSourceDeleteConfirmForm",
* },
* },
* admin_permission = "administer facets",
* config_prefix = "facet_source",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid"
* },
* config_export = {
* "id",
* "name",
* "filter_key",
* "url_processor"
* },
* links = {
* "canonical" = "/admin/config/search/facets/facet-sources/",
* "edit-form" = "/admin/config/search/facets/facet-sources/{facets_facet_source}/edit"
* }
* )
*/
class FacetSource extends ConfigEntityBase implements FacetSourceInterface {
/**
* The ID of the facet source.
*
* @var string
*/
protected $id;
/**
* A name to be displayed for the facet source.
*
* @var string
*/
protected $name;
/**
* The key, used for filters in the query string.
*
* @var string
*/
protected $filter_key;
/**
* The url processor name.
*
* @var string
*/
protected $url_processor = 'query_string';
/**
* {@inheritdoc}
*/
public function getName() {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setFilterKey($filter_key) {
$this->filter_key = $filter_key;
}
/**
* {@inheritdoc}
*/
public function getFilterKey() {
return $this->filter_key;
}
/**
* {@inheritdoc}
*/
public function setUrlProcessor($processor_name) {
$this->url_processor = $processor_name;
}
/**
* {@inheritdoc}
*/
public function getUrlProcessorName() {
return $this->url_processor;
}
}
......@@ -2,12 +2,12 @@
/**
* @file
* Contains \Drupal\facetapi\Exception\Exception.
* Contains \Drupal\facets\Exception\Exception.
*/
namespace Drupal\facetapi\Exception;
namespace Drupal\facets\Exception;
/**
* Represents an exception that occurred in some part of the Facet API.
* Represents an exception that occurred in some part of the Facets.
*/
class Exception extends \Exception {}
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\facetapi\Exception\InvalidProcessorException.
* Contains \Drupal\facets\Exception\InvalidProcessorException.
*/
namespace Drupal\facetapi\Exception;
namespace Drupal\facets\Exception;
/**
* Represents an exception that occurred when calling an invalid processor.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\facetapi\Exception\InvalidQueryTypeException.
* Contains \Drupal\facets\Exception\InvalidQueryTypeException.
*/
namespace Drupal\facetapi\Exception;
namespace Drupal\facets\Exception;
/**
* Represents an exception that occurred when calling an invalid query type.
......
<?php
/**
* @file
* Contains Drupal\facetapi\FacetInterface.
* Contains Drupal\facets\FacetInterface.
*/
namespace Drupal\facetapi;
namespace Drupal\facets;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
*
* The facet entity.
*/
interface FacetInterface extends ConfigEntityInterface {
......@@ -16,8 +17,10 @@ interface FacetInterface extends ConfigEntityInterface {
* Sets the facet's widget plugin id.
*
* @param string $widget
* The widget plugin id.
*
* @return $this
* Returns self
*/
public function setWidget($widget);
......@@ -25,142 +28,161 @@ interface FacetInterface extends ConfigEntityInterface {
* Returns the facet's widget plugin id.
*
* @return string
* The widget plugin id.
*/
public function getWidget();
/**
* Get field identifier.
* Returns field identifier.
*
* @return string
* The field identifier of this facet.
*/
public function getFieldIdentifier();
/**
* Set field identifier.
* Sets field identifier.
*
* @return mixed
* @param string $field_identifier
* The field identifier of this facet.
*
* @return $this
* Returns self.
*/
public function setFieldIdentifier($field_identifier);
/**
* Get the field alias used to identify the facet in the url.
* Returns the field alias used to identify the facet in the url.
*
* @return mixed
* @return string
* The field alias for the facet.
*/
public function getFieldAlias();
/**
* Get the field name of the facet as used in the index.
* Returns the field name of the facet as used in the index.
*
* @TODO: Check if fieldIdentifier can be used as well!
*
* @return mixed
* @return string
* The name of the facet.
*/
public function getName();
/**
* Returns the name of the facet for use in the URL.
*
* @return string
* The name of the facet for use in the URL.
*/
public function getUrlAlias();
/**
* Sets the name of the facet for use in the URL.
*
* @param string $url_alias
* The name of the facet for use in the URL.
*/
public function setUrlAlias($url_alias);
/**
* Sets an item with value to active.
*
* @param $value
* @param string $value
* An item that is active.
*/
public function setActiveItem($value);
/**
* Get all the active items in the facet.
* Returns all the active items in the facet.
*
* @return mixed
* An array containing all active items.
*/
public function getActiveItems();
/**
* Check if a value is active.
* Checks if a value is active.
*
* @param string $value
* The value to be checked.
*
* @return bool
* Is an active value.
*/
public function isActiveValue($value);
/**
* Get the result for the facet.
* Returns the result for the facet.
*
* @return \Drupal\facetapi\Result\ResultInterface[] $results
* @return \Drupal\facets\Result\ResultInterface[] $results
* The results of the facet.
*/
public function getResults();
/**
* Sets the reuslts for the facet.
* Sets the results for the facet.
*
* @param \Drupal\facetapi\Result\ResultInterface[] $results
* @param \Drupal\facets\Result\ResultInterface[] $results
* The results of the facet.
*/
public function setResults(array $results);
/**
* Get the query type instance.
* Sets an array of unfiltered results.
*
* @return string
*/
public function getQueryType();
/**
* Get the plugin name for the url processor.
* These unfiltered results are used to set the correct count of the actual
* facet results when using the OR query operator. They are not results value
* objects like those in ::$results.
*
* @return mixed
* @param array $all_results
* Unfiltered results.
*/
public function getUrlProcessorName();
public function setUnfilteredResults(array $all_results = []);
/**
* Retrieves an option.
*
* @param string $name
* The name of an option.
* @param mixed $default
* The value return if the option wasn't set.
* Returns an array of unfiltered results.
*
* @return mixed
* The value of the option.
*
* @see getOptions()
* @return array
* Unfiltered results.
*/
public function getOption($name, $default = NULL);
public function getUnfilteredResults();
/**
* Retrieves an array of all options.
* Returns the query type instance.
*
* @return array
* An associative array of option values, keyed by the option name.
* @return string
* The query type plugin being used.
*/
public function getOptions();
public function getQueryType();
/**
* Sets an option.
* Returns the query operator.
*
* @param string $name
* The name of an option.
* @param mixed $option
* The new option.
*
* @return $this
* @return string
* The query operator being used.
*/
public function setOption($name, $option);
public function getQueryOperator();
/**
* Sets the index's options.
* Returns the value of the exclude boolean.
*
* @param array $options
* The new index options.
* This will return true when the current facet's value should be exclusive
* from the search rather than inclusive.
* When this returns TRUE, the operator will be "<>" instead of "=".
*
* @return $this
* @return bool
* A boolean flag indicating if search should exlude selected facets
*/
public function setOptions(array $options);
public function getExclude();
/**
* Gets the facet manager plugin id.
* Returns the plugin name for the url processor.
*
* @return string
* The id of the url processor.
*/
public function getManagerPluginId();
public function getUrlProcessorName();
/**
* Sets a string representation of the Facet source plugin.
......@@ -168,55 +190,72 @@ interface FacetInterface extends ConfigEntityInterface {
* This is usually the name of the Search-api view.
*
* @param string $facet_source_id
* The facet source id.
*
* @return $this
* Returns self.
*/
public function setFacetSourceId($facet_source_id);
/**
* Sets the query operator.
*
* @param string $operator
* The query operator being used.
*/
public function setQueryOperator($operator);
/**
* Sets the exclude.
*
* @param bool $exclude
* A boolean flag indicating if search should exclude selected facets
*/
public function setExclude($exclude);
/**
* Returns the Facet source id.
*
* @return string
* The id of the facet source.
*/
public function getFacetSourceId();
/**
* Returns the plugin instance of a facet source.
*
* @return \Drupal\facetapi\FacetSource\FacetSourceInterface
* @return \Drupal\facets\FacetSource\FacetSourcePluginInterface
* The plugin instance for the facet source.
*/
public function getFacetSource();
/**
* Load the facet sources for this facet.
* Returns the facet source configuration object.
*
* @param bool|TRUE $only_enabled
*
* @return \Drupal\facetapi\FacetSource\FacetSourceInterface[]
* @return \Drupal\facets\FacetSourceInterface
* A facet source configuration object.
*/
public function getFacetSources($only_enabled = TRUE);
public function getFacetSourceConfig();
/**
* Get the path to which the facet should link.
* Loads the facet sources for this facet.
*
* @param string $path
*/
public function setPath($path);
/**
* Get the path to which the facet should link.
* @param bool|TRUE $only_enabled
* Only return enabled facet sources.
*
* @return NULL|string
* @return \Drupal\facets\FacetSource\FacetSourcePluginInterface[]
* An array of facet sources.
*/
public function getPath();
public function getFacetSources($only_enabled = TRUE);
/**
* Returns an array of processors with their configuration.
*
* @param bool|TRUE $only_enabled
* Only return enabled processors.
*
* @return \Drupal\facetapi\Processor\ProcessorInterface[]
* @return \Drupal\facets\Processor\ProcessorInterface[]
* An array of processors.
*/
public function getProcessors($only_enabled = TRUE);
......@@ -225,18 +264,26 @@ interface FacetInterface extends ConfigEntityInterface {
*
* @param string $stage
* The stage for which to return the processors. One of the
* \Drupal\facetapi\Processor\ProcessorInterface::STAGE_* constants.
* \Drupal\facets\Processor\ProcessorInterface::STAGE_* constants.
* @param bool $only_enabled
* (optional) If FALSE, also include disabled processors. Otherwise, only
* load enabled ones.
*
* @return \Drupal\facetapi\Processor\ProcessorInterface[]
* @return \Drupal\facets\Processor\ProcessorInterface[]
* An array of all enabled (or available, if if $only_enabled is FALSE)
* processors that support the given stage, ordered by the weight for that
* stage.
*/
public function getProcessorsByStage($stage, $only_enabled = TRUE);
/**
* Retrieves this facets's processor configs.
*
* @return array
* An array of processors and their configs.
*/
public function getProcessorConfigs();
/**
* Sets the "only visible when facet source is visible" boolean flag.
*
......@@ -245,14 +292,80 @@ interface FacetInterface extends ConfigEntityInterface {
* does not show the facet source.
*
* @return $this
* Returns self.
*/
public function setOnlyVisibleWhenFacetSourceIsVisible($only_visible_when_facet_source_is_visible);
/**
* Returns the "only visible when facet source is visible" boolean flag.
*
* @return boolean
* @return bool
* True when the facet is only shown on a page with the facet source.
*/
public function getOnlyVisibleWhenFacetSourceIsVisible();
/**
* Adds a processor for this facet.
*
* @param array $processor
* An array definition for a processor.
*/
public function addProcessor(array $processor);
/**
* Removes a processor for this facet.
*
* @param string $processor_id
* The plugin id of the processor.
*/
public function removeProcessor($processor_id);
/**
* Defines the no-results behavior.
*
* @param array $behavior
* The definition of the behavior.
*/
public function setEmptyBehavior(array $behavior);
/**
* Returns the defined no-results behavior or NULL if none defined.
*
* @return array|NULL
* The behavior definition or NULL.
*/
public function getEmptyBehavior();
/**
* Returns the configuration of the selected widget.
*
* @return array
* The configuration settings for the widget.
*/
public function getWidgetConfigs();
/**
* Sets the configuration for the widget of this facet.
*
* @param array $widget_config
* The configuration settings for the widget.
*/
public function setWidgetConfigs(array $widget_config);
/**
* Returns any additional configuration for this facet, not defined above.
*
* @return array
* An array of additional configuration for the facet.
*/
public function getFacetConfigs();
/**
* Defines any additional configuration for this facet not defined above.
*
* @param array $facet_config
* An array of additional configuration for the facet.
*/
public function setFacetConfigs(array $facet_config);
}
......@@ -2,15 +2,15 @@
/**
* @file
* Contains \Drupal\facetapi\FacetListBuilder.
* Contains \Drupal\facets\FacetListBuilder.
*/
namespace Drupal\facetapi;
namespace Drupal\facets;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\facetapi\FacetSource\FacetSourceInterface;
use Drupal\Core\Link;
/**
* Builds a listing of facet entities.
......@@ -81,7 +81,7 @@ class FacetListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\facetapi\FacetInterface $entity */
/** @var \Drupal\facets\FacetInterface $entity */
$row = parent::buildRow($entity);
$status_label = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
......@@ -98,14 +98,14 @@ class FacetListBuilder extends ConfigEntityListBuilder {
'data' => array(
'type' => array(
'data' => 'Facet',
'class' => array('facetapi-type'),
'class' => array('facets-type'),
),
'title' => array(
'data' => array(
'#type' => 'link',
'#title' => $entity->getName(),
'#suffix' => '<div>' . $entity->getFieldAlias() . ' - ' . $entity->getWidget() . '</div>',
) + $entity->urlInfo('edit-form')->toRenderArray(),
'#type' => 'link',
'#title' => $entity->getName(),
'#suffix' => '<div>' . $entity->getFieldAlias() . ' - ' . $entity->getWidget() . '</div>',
) + $entity->urlInfo('edit-form')->toRenderArray(),
'class' => array('search-api-title'),
),
'status' => array(
......@@ -120,14 +120,14 @@ class FacetListBuilder extends ConfigEntityListBuilder {
}
/**
* {@inheritdoc}
* Builds an array of facet sources for display in the overview.
*/
public function buildFacetSourceRow(array $facet_source = []) {
return array(
'data' => array(
'type' => array(
'data' => 'Facet source',
'class' => array('facetapi-type'),
'class' => array('facets-type'),
),
'title' => array(
'data' => $facet_source['id'],
......@@ -135,7 +135,13 @@ class FacetListBuilder extends ConfigEntityListBuilder {
'status' => array(
'data' => '',
),
'operations' => array(),
'operations' => array(
'data' => Link::createFromRoute(
$this->t('Configure'),
'entity.facets_facet_source.edit_form',
['source_id' => $facet_source['id']]
)->toRenderable(),
),
),
'class' => array('facet-source'),
);
......@@ -154,12 +160,12 @@ class FacetListBuilder extends ConfigEntityListBuilder {
'#markup' => $this->t(
'You currently have no facet sources defined. You should start by adding a facet source before creating facets.<br />
An example of a facet source is a view based on Search API or a Search API page.
Other modules can also implement a facet source by providing a plugin that implements the FacetSourceInterface.'
)
Other modules can also implement a facet source by providing a plugin that implements the FacetSourcePluginInterface.'
),
];
}
$list['#attached']['library'][] = 'facetapi/drupal.facetapi.admin_css';
$list['#attached']['library'][] = 'facets/drupal.facets.admin_css';
$list['#type'] = 'container';
......@@ -169,7 +175,9 @@ class FacetListBuilder extends ConfigEntityListBuilder {
'#rows' => array(),
'#empty' => $groups['lone_facets'] ? '' : $this->t('There are no facet sources or facets defined.'),
'#attributes' => array(
'id' => 'facetapi-groups-list',
'class' => array(
'facets-groups-list',
),
),
);
......@@ -206,7 +214,7 @@ class FacetListBuilder extends ConfigEntityListBuilder {
* - lone_facets: All facets that aren't attached to any facet source.
*/
public function loadGroups() {
$facet_source_plugin_manager = \Drupal::service('plugin.manager.facetapi.facet_source');
$facet_source_plugin_manager = \Drupal::service('plugin.manager.facets.facet_source');
$facets = $this->storage->loadMultiple();
$facet_sources = $facet_source_plugin_manager->getDefinitions();
......@@ -216,11 +224,11 @@ class FacetListBuilder extends ConfigEntityListBuilder {
foreach ($facet_sources as $facet_source) {
$facet_source_groups[$facet_source['id']] = [
'facet_source' => $facet_source,
'facets' => []
'facets' => [],
];
foreach ($facets as $facet) {
/** @var \Drupal\facetapi\FacetInterface $facet */
/** @var \Drupal\facets\FacetInterface $facet */
if ($facet->getFacetSourceId() == $facet_source['id']) {
$facet_source_groups[$facet_source['id']]['facets'][$facet->id()] = $facet;
// Remove this facet from $facet so it will finally only contain those
......
......@@ -2,23 +2,23 @@
/**
* @file
* Contains Drupal\facetapi\FacetManager\DefaultFacetManager.
* Contains Drupal\facets\FacetManager\DefaultFacetManager.
*/
namespace Drupal\facetapi\FacetManager;
namespace Drupal\facets\FacetManager;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\facetapi\Exception\InvalidProcessorException;
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\QueryType\QueryTypePluginManager;
use Drupal\facetapi\Widget\WidgetPluginManager;
use Drupal\facets\Exception\InvalidProcessorException;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\FacetSourcePluginManager;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\PreQueryProcessorInterface;
use Drupal\facets\Processor\ProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginManager;
use Drupal\facets\QueryType\QueryTypePluginManager;
use Drupal\facets\Widget\WidgetPluginManager;
/**
* The facet manager.
......@@ -33,30 +33,40 @@ class DefaultFacetManager {
/**
* The query type plugin manager.
*
* @var \Drupal\facets\QueryType\QueryTypePluginManager
* The query type plugin manager.
*/
protected $query_type_plugin_manager;
protected $queryTypePluginManager;
/**
* The facet source plugin manager.
*
* @var FacetSourcePluginManager
* @var \Drupal\facets\FacetSource\FacetSourcePluginManager
*/
protected $facet_source_manager;
protected $facetSourcePluginManager;
/**
* The processor plugin manager.
*
* @var \Drupal\facetapi\Processor\ProcessorPluginManager
* @var \Drupal\facets\Processor\ProcessorPluginManager
*/
protected $processorPluginManager;
/**
* The widget plugin manager.
*
* @var \Drupal\facets\Widget\WidgetPluginManager
*/
protected $processor_plugin_manager;
protected $widgetPluginManager;
/**
* An array of facets that are being rendered.
*
* @var \Drupal\facetapi\FacetInterface[]
* @var \Drupal\facets\FacetInterface[]
*
* @see \Drupal\facetapi\FacetInterface
* @see \Drupal\facetapi\Entity\Facet
* @see \Drupal\facets\FacetInterface
* @see \Drupal\facets\Entity\Facet
*/
protected $facets = [];
......@@ -68,7 +78,7 @@ class DefaultFacetManager {
*
* @var boolean
*
* @see FacetapiFacetManager::processFacets()
* @see FacetsFacetManager::processFacets()
*/
protected $processed = FALSE;
......@@ -84,7 +94,7 @@ class DefaultFacetManager {
*
* @var array
*
* @see FacetapiFacetManager::getFacetSettings()
* @see FacetsFacetManager::getFacetSettings()
*/
protected $settings = [];
......@@ -92,42 +102,53 @@ class DefaultFacetManager {
* The id of the facet source.
*
* @var string
* @see \Drupal\facetapi\FacetSource\FacetSourceInterface
*
* @see \Drupal\facets\FacetSource\FacetSourcePluginInterface
*/
protected $facetsource_id;
protected $facetSourceId;
/**
* Set the search id.
* The entity storage for facets.
*
* @param string
* The id of the facet source.
* @var \Drupal\Core\Entity\EntityStorageInterface|object
*/
public function setFacetSourceId($facetsource_id) {
$this->facetsource_id = $facetsource_id;
}
protected $facetStorage;
/**
* Constructs a new instance of the DefaultFacetManager.
*
* @param \Drupal\facetapi\QueryType\QueryTypePluginManager $query_type_plugin_manager
* @param \Drupal\facetapi\Widget\WidgetPluginManager $widget_plugin_manager
* @param \Drupal\facetapi\FacetSource\FacetSourcePluginManager $facet_source_manager
* @param \Drupal\facetapi\Processor\ProcessorPluginManager $processor_plugin_manager
* @param \Drupal\facets\QueryType\QueryTypePluginManager $query_type_plugin_manager
* The query type plugin manager.
* @param \Drupal\facets\Widget\WidgetPluginManager $widget_plugin_manager
* The widget plugin manager.
* @param \Drupal\facets\FacetSource\FacetSourcePluginManager $facet_source_manager
* The facet source plugin manager.
* @param \Drupal\facets\Processor\ProcessorPluginManager $processor_plugin_manager
* The processor plugin manager.
* @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
* The entity type plugin manager.
*/
public function __construct(QueryTypePluginManager $query_type_plugin_manager, WidgetPluginManager $widget_plugin_manager, FacetSourcePluginManager $facet_source_manager, ProcessorPluginManager $processor_plugin_manager, EntityTypeManager $entity_type_manager) {
$this->query_type_plugin_manager = $query_type_plugin_manager;
$this->widget_plugin_manager = $widget_plugin_manager;
$this->facet_source_manager = $facet_source_manager;
$this->processor_plugin_manager = $processor_plugin_manager;
$this->facet_storage = $entity_type_manager->getStorage('facetapi_facet');
$this->queryTypePluginManager = $query_type_plugin_manager;
$this->widgetPluginManager = $widget_plugin_manager;
$this->facetSourcePluginManager = $facet_source_manager;
$this->processorPluginManager = $processor_plugin_manager;
$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.
*
......@@ -138,14 +159,20 @@ class DefaultFacetManager {
* The backend's native query object.
*/
public function alterQuery(&$query) {
/** @var \Drupal\facetapi\FacetInterface[] $facets */
/** @var \Drupal\facets\FacetInterface[] $facets */
foreach ($this->facets as $facet) {
// Make sure we don't alter queries for facets with a different source.
if ($facet->getFacetSourceId() == $this->facetsource_id) {
/** @var \Drupal\facetapi\QueryType\QueryTypeInterface $query_type_plugin */
$query_type_plugin = $this->query_type_plugin_manager->createInstance($facet->getQueryType(), ['query' => $query, 'facet' => $facet]);
$query_type_plugin->execute();
if ($facet->getFacetSourceId() == $this->facetSourceId) {
/** @var \Drupal\facets\QueryType\QueryTypeInterface $query_type_plugin */
$query_type_plugin = $this->queryTypePluginManager
->createInstance($facet->getQueryType(), ['query' => $query, 'facet' => $facet]);
$unfiltered_results = $query_type_plugin->execute();
// Save unfiltered results in facet.
if (!is_null($unfiltered_results)) {
$facet->setUnfilteredResults($unfiltered_results);
}
}
}
}
......@@ -153,27 +180,28 @@ class DefaultFacetManager {
/**
* Returns enabled facets for the searcher associated with this FacetManager.
*
* @return \Drupal\facetapi\FacetInterface[]
* @return \Drupal\facets\FacetInterface[]
* 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.
*/
public function getFacetsourceId() {
return $this->facetsource_id;
public function getFacetSourceId() {
return $this->facetSourceId;
}
/**
* Initializes facet builds, sets the breadcrumb trail.
*
* Facets are built via FacetapiFacetProcessor objects. Facets only need to be
* processed, or built, once The FacetapiFacetManager::processed semaphore is
* Facets are built via FacetsFacetProcessor objects. Facets only need to be
* processed, or built, once The FacetsFacetManager::processed semaphore is
* set when this method is called ensuring that facets are built only once
* regardless of how many times this method is called.
*/
......@@ -187,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.
......@@ -197,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->processor_plugin_manager->createInstance($processor->getPluginDefinition()['id']);
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.
......@@ -223,7 +248,8 @@ class DefaultFacetManager {
* Before doing any rendering, the processors that implement the
* BuildProcessorInterface enabled on this facet will run.
*
* @param \Drupal\facetapi\FacetInterface $facet
* @param \Drupal\facets\FacetInterface $facet
* The facet we should build.
*
* @return array
* Facet render arrays.
......@@ -236,7 +262,7 @@ class DefaultFacetManager {
$facet = $this->facets[$facet->id()];
// @TODO: inject the searcher id on create of the FacetManager.
$this->facetsource_id = $facet->getFacetSourceId();
$this->facetSourceId = $facet->getFacetSourceId();
if ($facet->getOnlyVisibleWhenFacetSourceIsVisible()) {
// Block rendering and processing should be stopped when the facet source
......@@ -256,37 +282,35 @@ class DefaultFacetManager {
// 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.
// @see \Drupal\facets\Processor\BuildProcessorInterface.
// @see \Drupal\facets\Processor\WidgetOrderProcessorInterface.
$results = $facet->getResults();
foreach ($facet->getProcessors() as $processor) {
$processor_definition = $this->processor_plugin_manager->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->processor_plugin_manager->createInstance($processor->getPluginDefinition()['id']);
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);
// No results behavior handling. Return a custom text or false depending on
// settings.
if (empty($facet->getResults())) {
$empty_behavior = $facet->getOption('empty_behavior');
if($empty_behavior['behavior'] == 'text'){
$empty_behavior = $facet->getEmptyBehavior();
if ($empty_behavior['behavior'] == 'text') {
return ['#markup' => $empty_behavior['text']];
}else{
}
else {
return;
}
}
// Let the widget plugin render the facet.
/** @var \Drupal\facetapi\Widget\WidgetInterface $widget */
$widget = $this->widget_plugin_manager->createInstance($facet->getWidget());
/** @var \Drupal\facets\Widget\WidgetInterface $widget */
$widget = $this->widgetPluginManager->createInstance($facet->getWidget());
return $widget->build($facet);
}
......@@ -296,14 +320,29 @@ class DefaultFacetManager {
*/
public function updateResults() {
// Get an instance of the facet source.
/** @var \drupal\facetapi\FacetSource\FacetSourceInterface $facet_source_plugin */
$facet_source_plugin = $this->facet_source_manager->createInstance($this->facetsource_id);
/** @var \drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source_plugin */
$facet_source_plugin = $this->facetSourcePluginManager->createInstance($this->facetSourceId);
$facet_source_plugin->fillFacetsWithResults($this->facets);
}
foreach ($this->facets as $facet) {
$facet->setPath($facet_source_plugin->getPath());
}
/**
* Returns one of the processed facets.
*
* Returns one of the processed facets, this is a facet with filled results.
* Keep in mind that if you want to have the facet's build processor executed,
* there needs to be an extra call to the FacetManager::build with the facet
* returned here as argument.
*
* @param string $facet_id
* The id of the facet.
*
* @return \Drupal\facets\FacetInterface|NULL
* The updated facet if it exists, NULL otherwise.
*/
public function returnProcessedFacet($facet_id) {
$this->processFacets();
return $this->facets[$facet_id];
}
}
......@@ -2,18 +2,19 @@
/**
* @file
* Contains \Drupal\facetapi\FacetSource\FacetSourceDeriverBase.
* Contains \Drupal\facets\FacetSource\FacetSourceDeriverBase.
*/
namespace Drupal\facetapi\FacetSource;
namespace Drupal\facets\FacetSource;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* A base class for facet source derivers.
*/
abstract class FacetSourceDeriverBase implements ContainerDeriverInterface {
......@@ -81,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.
*
......
<?php
/**+
/**
* @file
* Contains \Drupal\facetapi\FacetSource\FacetSourcePluginBase.
* Contains \Drupal\facets\FacetSource\FacetSourcePluginBase.
*/
namespace Drupal\facetapi\FacetSource;
namespace Drupal\facets\FacetSource;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\FacetApi\FacetInterface;
use Drupal\Facets\FacetInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Defines a base class from which other facet sources may extend.
......@@ -21,17 +23,17 @@ use Drupal\FacetApi\FacetInterface;
* - label: The human-readable name of the datasource, translated.
* - description: A human-readable description for the datasource, translated.
*
* @see \Drupal\facetapi\Annotation\FacetApiFacetSource
* @see \Drupal\facetapi\FacetSource\FacetSourcePluginManager
* @see \Drupal\facetapi\FacetSource\FacetSourceInterface
* @see \Drupal\facets\Annotation\FacetsFacetSource
* @see \Drupal\facets\FacetSource\FacetSourcePluginManager
* @see \Drupal\facets\FacetSource\FacetSourcePluginInterface
* @see plugin_api
*/
abstract class FacetSourcePluginBase extends PluginBase implements FacetSourceInterface, ContainerFactoryPluginInterface {
abstract class FacetSourcePluginBase extends PluginBase implements FacetSourcePluginInterface, ContainerFactoryPluginInterface {
/**
* The plugin manager.
*
* @var \Drupal\facetapi\QueryType\QueryTypePluginManager
* @var \Drupal\facets\QueryType\QueryTypePluginManager
*/
protected $queryTypePluginManager;
......@@ -42,17 +44,23 @@ abstract class FacetSourcePluginBase extends PluginBase implements FacetSourceIn
*/
protected $keys;
/**
* The facet we're editing for.
*
* @var \Drupal\facets\FacetInterface
*/
protected $facet;
/**
* {@inheritdoc}
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
$query_type_plugin_manager
) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, $query_type_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->queryTypePluginManager = $query_type_plugin_manager;
if (isset($configuration['facet'])) {
$this->facet = $configuration['facet'];
}
}
/**
......@@ -60,8 +68,8 @@ abstract class FacetSourcePluginBase extends PluginBase implements FacetSourceIn
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
// Insert the plugin manager for query types.
/** @var \Drupal\facetapi\QueryType\QueryTypePluginManager $query_type_plugin_manager */
$query_type_plugin_manager = $container->get('plugin.manager.facetapi.query_type');
/** @var \Drupal\facets\QueryType\QueryTypePluginManager $query_type_plugin_manager */
$query_type_plugin_manager = $container->get('plugin.manager.facets.query_type');
return new static($configuration, $plugin_id, $plugin_definition, $query_type_plugin_manager);
}
......@@ -101,4 +109,21 @@ abstract class FacetSourcePluginBase extends PluginBase implements FacetSourceIn
public function getSearchKeys() {
return $this->keys;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$facet_source_id = $this->facet->getFacetSourceId();
$field_identifier = $form_state->getValue('facet_source_configs')[$facet_source_id]['field_identifier'];
$this->facet->setFieldIdentifier($field_identifier);
}
}
......@@ -2,62 +2,55 @@
/**
* @file
* Contains \Drupal\facetapi\FacetSource\FacetSourceInterface.
* Contains \Drupal\facets\FacetSource\FacetSourcePluginInterface.
*/
namespace Drupal\facetapi\FacetSource;
namespace Drupal\facets\FacetSource;
use Drupal\Core\Form\FormStateInterface;
use Drupal\facetapi\FacetInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\facets\FacetInterface;
/**
* Describes a source for facet items.
*
* A facet source is used to abstract the data source where facets can be added
* to. A good example of this is a search api view. There are other possible
* facet data sources, these all implement the FacetSourceInterface.
* facet data sources, these all implement the FacetSourcePluginInterface.
*
* @see plugin_api
*/
interface FacetSourceInterface {
interface FacetSourcePluginInterface extends PluginFormInterface {
/**
* Adds a configuration form for this facet source.
* Fills the facet entities with results from the facet source.
*
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
* @param \Drupal\facetapi\FacetInterface $facet
* @param \Drupal\facetapi\FacetSource\FacetSourceInterface $facet_source
* @param \Drupal\facets\FacetInterface[] $facets
* The configured facets.
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet, FacetSourceInterface $facet_source);
public function fillFacetsWithResults($facets);
/**
* Fill in facet data in to the configured facets.
* 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.
*
* @param \Drupal\facetapi\FacetInterface[] $facets
* @return string[]
* array of allowed query types
*
* @return mixed
* @throws \Drupal\facets\Exception\Exception
* An error when no query types are found.
*/
public function fillFacetsWithResults($facets);
public function getQueryTypesForFacet(FacetInterface $facet);
/**
* Returns the path where a facet should link to.
*
* @return string
* The path of the facet.
*/
public function getPath();
/**
* Get the allowed query types for a given facet for the facet source.
*
* @param \Drupal\facetapi\FacetInterface $facet
*
* @return array of allowed query types
*
* @throws \Drupal\facetapi\Exception\Exception
*/
public function getQueryTypesForFacet(FacetInterface $facet);
/**
* Returns true if the Facet source is being rendered in the current request.
*
......@@ -65,7 +58,8 @@ interface FacetSourceInterface {
* when facet source visibility: "being rendered" is configured in the facet
* visibility settings.
*
* @return boolean
* @return bool
* True when the facet is rendered on the same page.
*/
public function isRenderedInCurrentRequest();
......@@ -76,6 +70,7 @@ interface FacetSourceInterface {
* is keyed by the field's machine name and has values of the field's label.
*
* @return array
* An array of available fields.
*/
public function getFields();
......@@ -91,7 +86,7 @@ interface FacetSourceInterface {
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.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\facetapi\FacetSource\FacetSourcePluginManager.
* Contains \Drupal\facets\FacetSource\FacetSourcePluginManager.
*/
namespace Drupal\facetapi\FacetSource;
namespace Drupal\facets\FacetSource;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
......@@ -14,25 +14,17 @@ use Drupal\Core\Plugin\DefaultPluginManager;
/**
* Manages facet source plugins.
*
* @see \Drupal\facetapi\Annotation\FacetApiFacetSource
* @see \Drupal\facetapi\FacetSource\FacetSourcePluginBase
* @see \Drupal\facets\Annotation\FacetsFacetSource
* @see \Drupal\facets\FacetSource\FacetSourcePluginBase
* @see plugin_api
*/
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/facetapi/facet_source', $namespaces, $module_handler, 'Drupal\facetapi\FacetSource\FacetSourceInterface', 'Drupal\facetapi\Annotation\FacetApiFacetSource');
parent::__construct('Plugin/facets/facet_source', $namespaces, $module_handler, 'Drupal\facets\FacetSource\FacetSourcePluginInterface', 'Drupal\facets\Annotation\FacetsFacetSource');
}
}