class Facet in Facets 8
Defines the facet configuration entity.
Plugin annotation
@ConfigEntityType(
id = "facets_facet",
label = @Translation("Facet"),
handlers = {
"storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage",
"list_builder" = "Drupal\facets\FacetListBuilder",
"form" = {
"default" = "Drupal\facets\Form\FacetSettingsForm",
"edit" = "Drupal\facets\Form\FacetForm",
"settings" = "Drupal\facets\Form\FacetSettingsForm",
"clone" = "Drupal\facets\Form\FacetCloneForm",
"delete" = "Drupal\Core\Entity\EntityDeleteForm",
},
},
admin_permission = "administer facets",
config_prefix = "facet",
entity_keys = {
"id" = "id",
"label" = "name",
"uuid" = "uuid",
"status" = "status",
"weight" = "weight"
},
config_export = {
"id",
"name",
"url_alias",
"weight",
"min_count",
"show_only_one_result",
"field_identifier",
"facet_source_id",
"widget",
"query_operator",
"use_hierarchy",
"keep_hierarchy_parents_active",
"expand_hierarchy",
"enable_parent_when_child_gets_disabled",
"hard_limit",
"exclude",
"only_visible_when_facet_source_is_visible",
"processor_configs",
"empty_behavior",
"show_title"
},
links = {
"collection" = "/admin/config/search/facets",
"add-form" = "/admin/config/search/facets/add-facet",
"edit-form" = "/admin/config/search/facets/{facets_facet}/edit",
"settings-form" = "/admin/config/search/facets/{facets_facet}/settings",
"clone-form" = "/admin/config/search/facets/{facets_facet}/clone",
"delete-form" = "/admin/config/search/facets/{facets_facet}/delete",
}
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements ConfigEntityInterface uses SynchronizableEntityTrait, PluginDependencyTrait
- class \Drupal\facets\Entity\Facet implements FacetInterface
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements ConfigEntityInterface uses SynchronizableEntityTrait, PluginDependencyTrait
Expanded class hierarchy of Facet
40 files declare their use of Facet
- ActiveWidgetOrderProcessorTest.php in tests/
src/ Unit/ Plugin/ processor/ ActiveWidgetOrderProcessorTest.php - ArrayWidgetTest.php in tests/
src/ Unit/ Plugin/ widget/ ArrayWidgetTest.php - BlockTestTrait.php in tests/
src/ Functional/ BlockTestTrait.php - BooleanItemProcessorTest.php in tests/
src/ Unit/ Plugin/ processor/ BooleanItemProcessorTest.php - CountLimitProcessorTest.php in tests/
src/ Unit/ Plugin/ processor/ CountLimitProcessorTest.php
5 string references to 'Facet'
- FacetBlockDeriver::getDerivativeDefinitions in src/
Plugin/ Block/ FacetBlockDeriver.php - Gets the definition of all derivatives of a base plugin.
- FacetListBuilder::buildRow in src/
FacetListBuilder.php - Builds a row for an entity in the entity listing.
- facets.facet.schema.yml in config/
schema/ facets.facet.schema.yml - config/schema/facets.facet.schema.yml
- facets_summary.facets_summary.schema.yml in modules/
facets_summary/ config/ schema/ facets_summary.facets_summary.schema.yml - modules/facets_summary/config/schema/facets_summary.facets_summary.schema.yml
- UrlIntegrationTest::testFacetUrlCanBeChanged in tests/
src/ Functional/ UrlIntegrationTest.php - Tests that modules can change the facet url.
File
- src/
Entity/ Facet.php, line 70
Namespace
Drupal\facets\EntityView source
class Facet extends ConfigEntityBase implements FacetInterface {
/**
* The ID of the facet.
*
* @var string
*/
protected $id;
/**
* A name to be displayed for the facet.
*
* @var string
*/
protected $name;
/**
* The name for the parameter when used in the URL.
*
* @var string
*/
protected $url_alias;
/**
* A string describing the facet.
*
* @var string
*/
protected $description;
/**
* The widget plugin definition.
*
* @var array
*/
protected $widget;
/**
* The widget plugin instance.
*
* @var \Drupal\facets\Widget\WidgetPluginBase
*/
protected $widgetInstance;
/**
* The hierarchy definition.
*
* @var array
*/
protected $hierarchy;
/**
* The hierarchy instance.
*
* @var \Drupal\facets\Hierarchy\HierarchyPluginBase
*/
protected $hierarchy_processor;
/**
* The operator to hand over to the query, currently AND | OR.
*
* @var string
*/
protected $query_operator;
/**
* Hard limit for the facet items.
*
* @var int
*/
protected $hard_limit;
/**
* A boolean flag indicating if search should exclude selected facets.
*
* @var bool
*/
protected $use_hierarchy = FALSE;
/**
* A boolean flag indicating if the parent results of a hierarchical facet
* should be kept active when a child becomes active.
*
* @var bool
*/
protected $keep_hierarchy_parents_active = FALSE;
/**
* A boolean indicating if hierarchical items should always be expanded.
*
* @var bool
*/
protected $expand_hierarchy = FALSE;
/**
* Wether or not parents should be enabled when a child gets disabled.
*
* @var bool
*/
protected $enable_parent_when_child_gets_disabled = TRUE;
/**
* A boolean flag indicating if search should exclude selected facets.
*
* @var bool
*/
protected $exclude = FALSE;
/**
* The field identifier.
*
* @var string
*/
protected $field_identifier;
/**
* The id of the facet source.
*
* @var string
*/
protected $facet_source_id;
/**
* The facet source belonging to this facet.
*
* @var \Drupal\facets\FacetSource\FacetSourcePluginInterface
*
* @see getFacetSource()
*/
protected $facet_source_instance = NULL;
/**
* The path all the links should point to.
*
* @var string
*/
protected $path;
/**
* The results.
*
* @var \Drupal\facets\Result\ResultInterface[]
*/
protected $results = [];
/**
* An array of active values.
*
* @var string[]
*/
protected $active_values = [];
/**
* An array containing the facet source plugins.
*
* @var array
*/
protected $facetSourcePlugins;
/**
* Cached information about the processors available for this facet.
*
* @var \Drupal\facets\Processor\ProcessorInterface[]|null
*
* @see loadProcessors()
*/
protected $processors;
/**
* Configuration for the processors. This is an array of arrays.
*
* @var array
*/
protected $processor_configs = [];
/**
* Is the facet only visible when the facet source is only visible.
*
* A boolean that defines whether or not the facet is only visible when the
* facet source is visible.
*
* @var bool
*/
protected $only_visible_when_facet_source_is_visible;
/**
* Determines if only one result can be selected in the facet at one time.
*
* @var bool
*/
protected $show_only_one_result = FALSE;
/**
* The no-result configuration.
*
* @var string[]
*/
protected $empty_behavior;
/**
* The widget plugin manager.
*
* @var \Drupal\facets\Widget\WidgetPluginManager
*/
protected $widget_plugin_manager;
/**
* The hierarchy plugin manager.
*
* @var \Drupal\facets\Hierarchy\HierarchyPluginManager
* The hierarchy plugin manager.
*/
protected $hierarchy_manager;
/**
* The facet source config object.
*
* @var \Drupal\Facets\FacetSourceInterface
* The facet source config object.
*/
protected $facetSourceConfig;
/**
* The facet weight.
*
* @var int
* The weight of the facet.
*/
protected $weight;
/**
* The minimum amount of results to show.
*
* @var int
* The minimum amount of results.
*/
protected $min_count = 1;
/**
* Returns the widget plugin manager.
*
* @return \Drupal\facets\Widget\WidgetPluginManager
* The widget plugin manager.
*/
public function getWidgetManager() {
return $this->widget_plugin_manager ?: \Drupal::service('plugin.manager.facets.widget');
}
/**
* Returns the hierarchy plugin manager.
*
* @return \Drupal\facets\Hierarchy\HierarchyPluginManager
* The hierarchy plugin manager.
*/
public function getHierarchyManager() {
return $this->hierarchy_manager ?: \Drupal::service('plugin.manager.facets.hierarchy');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function setWidget($id, array $configuration = NULL) {
if ($configuration === NULL) {
$instance = $this
->getWidgetManager()
->createInstance($id);
// Get the default configuration for this plugin.
$configuration = $instance
->getConfiguration();
}
$this->widget = [
'type' => $id,
'config' => $configuration,
];
// Unset the widget instance, if exists.
unset($this->widgetInstance);
}
/**
* {@inheritdoc}
*/
public function getWidget() {
return $this->widget;
}
/**
* {@inheritdoc}
*/
public function getWidgetInstance() {
if ($this->widget === NULL) {
throw new InvalidProcessorException();
}
if (!isset($this->widgetInstance)) {
$definition = $this
->getWidget();
$this->widgetInstance = $this
->getWidgetManager()
->createInstance($definition['type'], (array) $definition['config']);
}
return $this->widgetInstance;
}
/**
* {@inheritdoc}
*/
public function setHierarchy($id, array $configuration = NULL) {
if ($configuration === NULL) {
$instance = $this
->getHierarchyManager()
->createInstance($id);
// Get the default configuration for this plugin.
$configuration = $instance
->getConfiguration();
}
$this->hierarchy = [
'type' => $id,
'config' => $configuration,
];
// Unset the hierarchy instance, if exists.
unset($this->hierarchy_instance);
}
/**
* {@inheritdoc}
*/
public function getHierarchy() {
// TODO: do not hardcode on taxonomy, make this configurable (or better,
// autoselected depending field type).
return [
'type' => 'taxonomy',
'config' => [],
];
}
/**
* {@inheritdoc}
*/
public function getHierarchyInstance() {
if (!isset($this->hierarchy_instance)) {
$definition = $this
->getHierarchy();
$this->hierarchy_instance = $this
->getHierarchyManager()
->createInstance($definition['type'], (array) $definition['config']);
}
return $this->hierarchy_instance;
}
/**
* Retrieves all processors supported by this facet.
*
* @return \Drupal\facets\Processor\ProcessorInterface[]
* The loaded processors, keyed by processor ID.
*/
protected function loadProcessors() {
if (is_array($this->processors)) {
return $this->processors;
}
/* @var $processor_plugin_manager \Drupal\facets\Processor\ProcessorPluginManager */
$processor_plugin_manager = \Drupal::service('plugin.manager.facets.processor');
$processor_settings = $this
->getProcessorConfigs();
foreach ($processor_plugin_manager
->getDefinitions() as $name => $processor_definition) {
if (class_exists($processor_definition['class']) && empty($this->processors[$name])) {
// Create our settings for this processor.
$settings = empty($processor_settings[$name]['settings']) ? [] : $processor_settings[$name]['settings'];
$settings['facet'] = $this;
/* @var $processor \Drupal\facets\Processor\ProcessorInterface */
$processor = $processor_plugin_manager
->createInstance($name, $settings);
$this->processors[$name] = $processor;
}
elseif (!class_exists($processor_definition['class'])) {
\Drupal::logger('facets')
->warning('Processor @id specifies a non-existing @class.', [
'@id' => $name,
'@class' => $processor_definition['class'],
]);
}
}
return $this->processors;
}
/**
* {@inheritdoc}
*/
public function getProcessorConfigs() {
return !empty($this->processor_configs) ? $this->processor_configs : [];
}
/**
* {@inheritdoc}
*/
public function getQueryType() {
$facet_source = $this
->getFacetSource();
if (is_null($facet_source)) {
throw new Exception("No facet source defined for facet.");
}
$query_types = $facet_source
->getQueryTypesForFacet($this);
// Get the widget configured for this facet.
/** @var \Drupal\facets\Widget\WidgetPluginInterface $widget */
$widget = $this
->getWidgetInstance();
// Give the widget the chance to select a preferred query type. This is
// needed for widget that have different query type. For example the need
// for a range query.
$widgetQueryType = $widget
->getQueryType();
// Allow widgets to also specify a query type.
$processorQueryTypes = [];
foreach ($this
->getProcessors() as $processor) {
$pqt = $processor
->getQueryType();
if ($pqt !== NULL) {
$processorQueryTypes[] = $pqt;
}
}
$processorQueryTypes = array_flip($processorQueryTypes);
// The widget has made no decision and neither have the processors.
if ($widgetQueryType === NULL && count($processorQueryTypes) === 0) {
return $this
->pickQueryType($query_types, 'string');
}
// The widget has made no decision but the processors have made 1 decision.
if ($widgetQueryType === NULL && count($processorQueryTypes) === 1) {
return $this
->pickQueryType($query_types, key($processorQueryTypes));
}
// The widget has made a decision and the processors have not.
if ($widgetQueryType !== NULL && count($processorQueryTypes) === 0) {
return $this
->pickQueryType($query_types, $widgetQueryType);
}
// The widget has made a decision and the processors have 1, being the same.
if ($widgetQueryType !== NULL && count($processorQueryTypes) === 1 && key($processorQueryTypes) === $widgetQueryType) {
return $this
->pickQueryType($query_types, $widgetQueryType);
}
// Invalid choice.
throw new InvalidQueryTypeException("Invalid query type combination in widget / processors. Widget: {$widgetQueryType}, Processors: " . implode(', ', array_keys($processorQueryTypes)) . ".");
}
/**
* Choose the query type.
*
* @param array $allTypes
* An array of query type definitions.
* @param string $type
* The chose query type.
*
* @return string
* The class name of the chose query type.
*
* @throws \Drupal\facets\Exception\InvalidQueryTypeException
*/
protected function pickQueryType(array $allTypes, $type) {
if (!isset($allTypes[$type])) {
throw new InvalidQueryTypeException("Query type {$type} doesn't exist.");
}
return $allTypes[$type];
}
/**
* {@inheritdoc}
*/
public function setQueryOperator($operator = '') {
return $this->query_operator = $operator;
}
/**
* {@inheritdoc}
*/
public function getQueryOperator() {
return $this->query_operator ?: 'or';
}
/**
* {@inheritdoc}
*/
public function setUseHierarchy($use_hierarchy) {
return $this->use_hierarchy = $use_hierarchy;
}
/**
* {@inheritdoc}
*/
public function getUseHierarchy() {
return $this->use_hierarchy;
}
/**
* {@inheritdoc}
*/
public function setKeepHierarchyParentsActive($keep_hierarchy_parents_active) {
return $this->keep_hierarchy_parents_active = $keep_hierarchy_parents_active;
}
/**
* {@inheritdoc}
*/
public function getKeepHierarchyParentsActive() {
return $this->keep_hierarchy_parents_active;
}
/**
* {@inheritdoc}
*/
public function setExpandHierarchy($expand_hierarchy) {
return $this->expand_hierarchy = $expand_hierarchy;
}
/**
* {@inheritdoc}
*/
public function getExpandHierarchy() {
return $this->expand_hierarchy;
}
/**
* {@inheritdoc}
*/
public function setEnableParentWhenChildGetsDisabled($enable_parent_when_child_gets_disabled) {
return $this->enable_parent_when_child_gets_disabled = $enable_parent_when_child_gets_disabled;
}
/**
* {@inheritdoc}
*/
public function getEnableParentWhenChildGetsDisabled() {
return $this->enable_parent_when_child_gets_disabled;
}
/**
* {@inheritdoc}
*/
public function setHardLimit($limit) {
return $this->hard_limit = $limit;
}
/**
* {@inheritdoc}
*/
public function getHardLimit() {
return $this->hard_limit ?: 0;
}
/**
* {@inheritdoc}
*/
public function getDataDefinition() {
return $this
->getFacetSource()
->getDataDefinition($this->field_identifier);
}
/**
* {@inheritdoc}
*/
public function setExclude($exclude) {
return $this->exclude = $exclude;
}
/**
* {@inheritdoc}
*/
public function getExclude() {
return $this->exclude;
}
/**
* {@inheritdoc}
*/
public function getFieldAlias() {
// For now, create the field alias based on the field identifier.
$field_alias = preg_replace('/[:\\/]+/', '_', $this->field_identifier);
return $field_alias;
}
/**
* {@inheritdoc}
*/
public function setActiveItem($value) {
if (!in_array($value, $this->active_values)) {
$this->active_values[] = $value;
}
}
/**
* {@inheritdoc}
*/
public function getActiveItems() {
return $this->active_values;
}
/**
* {@inheritdoc}
*/
public function setActiveItems(array $values) {
$this->active_values = $values;
}
/**
* {@inheritdoc}
*/
public function getFieldIdentifier() {
return $this->field_identifier;
}
/**
* {@inheritdoc}
*/
public function setFieldIdentifier($field_identifier) {
$this->field_identifier = $field_identifier;
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function getUrlAlias() {
return $this->url_alias;
}
/**
* {@inheritdoc}
*/
public function setUrlAlias($url_alias) {
$this->url_alias = $url_alias;
}
/**
* {@inheritdoc}
*/
public function setFacetSourceId($facet_source_id) {
$this->facet_source_id = $facet_source_id;
}
/**
* {@inheritdoc}
*/
public function getFacetSourceId() {
return $this->facet_source_id;
}
/**
* {@inheritdoc}
*/
public function getFacetSource() {
if (is_null($this->facet_source_instance) && $this->facet_source_id) {
/* @var $facet_source_plugin_manager \Drupal\facets\FacetSource\FacetSourcePluginManager */
$facet_source_plugin_manager = \Drupal::service('plugin.manager.facets.facet_source');
if (!$facet_source_plugin_manager
->hasDefinition($this->facet_source_id)) {
return NULL;
}
$this->facet_source_instance = $facet_source_plugin_manager
->createInstance($this->facet_source_id, [
'facet' => $this,
]);
}
return $this->facet_source_instance;
}
/**
* {@inheritdoc}
*/
public function getShowOnlyOneResult() {
return $this->show_only_one_result;
}
/**
* {@inheritdoc}
*/
public function setShowOnlyOneResult($show_only_one_result) {
$this->show_only_one_result = $show_only_one_result;
}
/**
* {@inheritdoc}
*/
public function getFacetSourceConfig() {
// Return the facet source config object, if it's already set on the facet.
if ($this->facetSourceConfig instanceof FacetSource) {
return $this->facetSourceConfig;
}
$storage = \Drupal::entityTypeManager()
->getStorage('facets_facet_source');
$source_id = str_replace(':', '__', $this->facet_source_id);
// Load and return the facet source config object from the storage.
$facet_source = $storage
->load($source_id);
if ($facet_source instanceof FacetSource) {
$this->facetSourceConfig = $facet_source;
return $this->facetSourceConfig;
}
// 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([
'id' => $source_id,
'name' => $this->facet_source_id,
'filter_key' => 'f',
'url_processor' => 'query_string',
], 'facets_facet_source');
return $facet_source;
}
/**
* {@inheritdoc}
*/
public function getResults() {
return $this->results;
}
/**
* {@inheritdoc}
*/
public function setResults(array $results) {
$this->results = $results;
// If there are active values,
// set the results which are active to active.
if (count($this->active_values)) {
foreach ($this->results as $result) {
if (in_array($result
->getRawValue(), $this->active_values)) {
$result
->setActiveState(TRUE);
}
}
}
}
/**
* {@inheritdoc}
*/
public function isActiveValue($value) {
$is_active = FALSE;
if (in_array($value, $this->active_values)) {
$is_active = TRUE;
}
return $is_active;
}
/**
* {@inheritdoc}
*/
public function getFacetSources($only_enabled = FALSE) {
if (!isset($this->facetSourcePlugins)) {
$this->facetSourcePlugins = [];
/* @var $facet_source_plugin_manager \Drupal\facets\FacetSource\FacetSourcePluginManager */
$facet_source_plugin_manager = \Drupal::service('plugin.manager.facets.facet_source');
foreach ($facet_source_plugin_manager
->getDefinitions() as $name => $facet_source_definition) {
if (class_exists($facet_source_definition['class']) && empty($this->facetSourcePlugins[$name])) {
// Create our settings for this facet source..
$config = isset($this->facetSourcePlugins[$name]) ? $this->facetSourcePlugins[$name] : [];
/* @var $facet_source \Drupal\facets\FacetSource\FacetSourcePluginInterface */
$facet_source = $facet_source_plugin_manager
->createInstance($name, $config);
$this->facetSourcePlugins[$name] = $facet_source;
}
elseif (!class_exists($facet_source_definition['class'])) {
\Drupal::logger('facets')
->warning('Facet Source @id specifies a non-existing @class.', [
'@id' => $name,
'@class' => $facet_source_definition['class'],
]);
}
}
}
// Filter facet sources by status if required.
if (!$only_enabled) {
return $this->facetSourcePlugins;
}
return array_intersect_key($this->facetSourcePlugins, array_flip($this->facetSourcePlugins));
}
/**
* {@inheritdoc}
*/
public function getProcessors($only_enabled = TRUE) {
$processors = $this
->loadProcessors();
// Filter processors by status if required. Enabled processors are those
// which have settings in the processor_configs.
if ($only_enabled) {
$processors_settings = $this
->getProcessorConfigs();
$processors = array_intersect_key($processors, $processors_settings);
}
return $processors;
}
/**
* {@inheritdoc}
*/
public function getProcessorsByStage($stage, $only_enabled = TRUE) {
$processors = $this
->getProcessors($only_enabled);
$processor_settings = $this
->getProcessorConfigs();
$processor_weights = [];
// Get a list of all processors for given stage.
foreach ($processors as $name => $processor) {
if ($processor
->supportsStage($stage)) {
if (!empty($processor_settings[$name]['weights'][$stage])) {
$processor_weights[$name] = $processor_settings[$name]['weights'][$stage];
}
else {
$processor_weights[$name] = $processor
->getDefaultWeight($stage);
}
}
}
// Sort requested processors by weight.
asort($processor_weights);
$return_processors = [];
foreach ($processor_weights as $name => $weight) {
$return_processors[$name] = $processors[$name];
}
return $return_processors;
}
/**
* {@inheritdoc}
*/
public function setOnlyVisibleWhenFacetSourceIsVisible($only_visible_when_facet_source_is_visible) {
$this->only_visible_when_facet_source_is_visible = $only_visible_when_facet_source_is_visible;
}
/**
* {@inheritdoc}
*/
public function getOnlyVisibleWhenFacetSourceIsVisible() {
return $this->only_visible_when_facet_source_is_visible;
}
/**
* {@inheritdoc}
*/
public function addProcessor(array $processor) {
$this->processor_configs[$processor['processor_id']] = [
'processor_id' => $processor['processor_id'],
'weights' => $processor['weights'],
'settings' => $processor['settings'],
];
// Sort the processors so we won't have unnecessary changes.
ksort($this->processor_configs);
}
/**
* {@inheritdoc}
*/
public function removeProcessor($processor_id) {
unset($this->processor_configs[$processor_id]);
unset($this->processors[$processor_id]);
}
/**
* {@inheritdoc}
*/
public function getEmptyBehavior() {
return $this->empty_behavior;
}
/**
* {@inheritdoc}
*/
public function setEmptyBehavior(array $empty_behavior) {
$this->empty_behavior = $empty_behavior;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->weight;
}
/**
* {@inheritdoc}
*/
public function setWeight($weight) {
$this->weight = $weight;
}
/**
* {@inheritdoc}
*/
public function setMinCount($min_count) {
$this->min_count = $min_count;
}
/**
* {@inheritdoc}
*/
public function getMinCount() {
return $this->min_count;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
parent::calculateDependencies();
$source = $this
->getFacetSource();
if ($source === NULL) {
return $this;
}
$facet_dependencies = $source
->calculateDependencies();
if (!empty($facet_dependencies)) {
$this
->addDependencies($facet_dependencies);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if (!$update) {
self::clearBlockCache();
}
}
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
self::clearBlockCache();
}
/**
* Clear the block cache.
*
* This includes resetting the shared plugin block manager as this can result
* in the block definition cache being rebuilt in the same request with stale
* static caches in the deriver.
*/
protected static function clearBlockCache() {
$container = \Drupal::getContainer();
// If the block manager has already been loaded, we may have stale static
// caches in the facet deriver, so lets clear it out.
$container
->set('plugin.manager.block', NULL);
// Now rebuild the cache to force a fresh set of data.
$container
->get('plugin.manager.block')
->clearCachedDefinitions();
}
/**
* Remove the facet lazy built data when the facet is serialized.
*/
public function __sleep() {
unset($this->facet_source_instance);
unset($this->processors);
return parent::__sleep();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ConfigEntityBase:: |
private | property | Whether the config is being deleted by the uninstall process. | |
ConfigEntityBase:: |
protected | property | The language code of the entity's default language. | |
ConfigEntityBase:: |
protected | property | The original ID of the configuration entity. | |
ConfigEntityBase:: |
protected | property | The enabled/disabled status of the configuration entity. | 4 |
ConfigEntityBase:: |
protected | property | Third party entity settings. | |
ConfigEntityBase:: |
protected | property | Trust supplied data and not use configuration schema on save. | |
ConfigEntityBase:: |
protected | property | The UUID for this entity. | |
ConfigEntityBase:: |
protected | property | Information maintained by Drupal core about configuration. | |
ConfigEntityBase:: |
protected | function | Overrides \Drupal\Core\Entity\DependencyTrait:addDependency(). | |
ConfigEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Disables the configuration entity. Overrides ConfigEntityInterface:: |
1 |
ConfigEntityBase:: |
public | function |
Enables the configuration entity. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Returns the value of a property. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityBase:: |
|
ConfigEntityBase:: |
protected static | function | Gets the configuration manager. | |
ConfigEntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the configuration dependencies. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the original ID. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
protected | function | Gets the typed config manager. | |
ConfigEntityBase:: |
public | function |
Gets whether on not the data is trusted. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
protected static | function |
Override to never invalidate the individual entities' cache tags; the
config system already invalidates them. Overrides EntityBase:: |
|
ConfigEntityBase:: |
protected | function |
Override to never invalidate the entity's cache tag; the config system
already invalidates it. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Checks whether this entity is installable. Overrides ConfigEntityInterface:: |
2 |
ConfigEntityBase:: |
public | function |
Overrides Entity::isNew(). Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityInterface:: |
7 |
ConfigEntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase:: |
8 |
ConfigEntityBase:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides EntityBase:: |
13 |
ConfigEntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Sets the value of a property. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Sets the original ID. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Sets the status of the configuration entity. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function | ||
ConfigEntityBase:: |
public static | function | Helper callback for uasort() to sort configuration entities by weight and label. | 6 |
ConfigEntityBase:: |
public | function |
Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface:: |
4 |
ConfigEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
2 |
ConfigEntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Sets that the data should be trusted. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Unsets a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
10 |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. Aliased as: addDependencyTrait | |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public | function |
Checks data value access. Overrides AccessibleInterface:: |
1 |
EntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the identifier. Overrides EntityInterface:: |
11 |
EntityBase:: |
public | function |
Gets the label of the entity. Overrides EntityInterface:: |
6 |
EntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets an array of placeholders for this entity. | 2 |
EntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
Facet:: |
protected | property | An array of active values. | |
Facet:: |
protected | property | A string describing the facet. | |
Facet:: |
protected | property | The no-result configuration. | |
Facet:: |
protected | property | Wether or not parents should be enabled when a child gets disabled. | |
Facet:: |
protected | property | A boolean flag indicating if search should exclude selected facets. | |
Facet:: |
protected | property | A boolean indicating if hierarchical items should always be expanded. | |
Facet:: |
protected | property | The facet source config object. | |
Facet:: |
protected | property | An array containing the facet source plugins. | |
Facet:: |
protected | property | The id of the facet source. | |
Facet:: |
protected | property | The facet source belonging to this facet. | |
Facet:: |
protected | property | The field identifier. | |
Facet:: |
protected | property | Hard limit for the facet items. | |
Facet:: |
protected | property | The hierarchy definition. | |
Facet:: |
protected | property | The hierarchy plugin manager. | |
Facet:: |
protected | property | The hierarchy instance. | |
Facet:: |
protected | property | The ID of the facet. | |
Facet:: |
protected | property | A boolean flag indicating if the parent results of a hierarchical facet should be kept active when a child becomes active. | |
Facet:: |
protected | property | The minimum amount of results to show. | |
Facet:: |
protected | property | A name to be displayed for the facet. | |
Facet:: |
protected | property | Is the facet only visible when the facet source is only visible. | |
Facet:: |
protected | property | The path all the links should point to. | |
Facet:: |
protected | property | Cached information about the processors available for this facet. | |
Facet:: |
protected | property | Configuration for the processors. This is an array of arrays. | |
Facet:: |
protected | property | The operator to hand over to the query, currently AND | OR. | |
Facet:: |
protected | property | The results. | |
Facet:: |
protected | property | Determines if only one result can be selected in the facet at one time. | |
Facet:: |
protected | property | The name for the parameter when used in the URL. | |
Facet:: |
protected | property | A boolean flag indicating if search should exclude selected facets. | |
Facet:: |
protected | property | The facet weight. | |
Facet:: |
protected | property | The widget plugin definition. | |
Facet:: |
protected | property | The widget plugin instance. | |
Facet:: |
protected | property | The widget plugin manager. | |
Facet:: |
public | function |
Adds a processor for this facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityBase:: |
|
Facet:: |
protected static | function | Clear the block cache. | |
Facet:: |
public | function |
Returns all the active items in the facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the data definition from the facet field. Overrides FacetInterface:: |
|
Facet:: |
public | function | ||
Facet:: |
public | function |
Returns the defined no-results behavior or NULL if none defined. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the value of the enable_parent_when_child_gets_disabled boolean. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the value of the exclude boolean. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the value of the expand_hierarchy boolean. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the plugin instance of a facet source. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the facet source configuration object. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the Facet source id. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Loads the facet sources for this facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the field alias used to identify the facet in the url. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns field identifier. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the limit number for facet items. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the facet hierarchy definition. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the facet hierarchy instance. Overrides FacetInterface:: |
|
Facet:: |
public | function | Returns the hierarchy plugin manager. | |
Facet:: |
public | function |
Returns the value of the keep_hierarchy_parents_active boolean. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the minimum count of the result to show. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the field name of the facet as used in the index. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the "only visible when facet source is visible" boolean flag. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Retrieves this facets's processor configs. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns an array of processors with their configuration. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Loads this facets processors for a specific stage. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the query operator. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the query type instance. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the result for the facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the show_only_one_result option. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the name of the facet for use in the URL. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the value of the use_hierarchy boolean. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the weight of the facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the facet widget definition. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Returns the facet widget instance. Overrides FacetInterface:: |
|
Facet:: |
public | function | Returns the widget plugin manager. | |
Facet:: |
public | function |
Checks if a value is active. Overrides FacetInterface:: |
|
Facet:: |
protected | function | Retrieves all processors supported by this facet. | |
Facet:: |
protected | function | Choose the query type. | |
Facet:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityBase:: |
|
Facet:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: |
|
Facet:: |
public | function |
Removes a processor for this facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets an item with value to active. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Overwrites the active items. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Defines the no-results behavior. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the enable_parent_when_child_gets_disabled. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the exclude. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the expand_hierarchy. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets a string representation of the Facet source plugin. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets field identifier. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the hard limit of facet items. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the facet hierarchy definition. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the keep_hierarchy_parents_active. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the minimum count of the result to show. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the "only visible when facet source is visible" boolean flag. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the query operator. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the results for the facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the show_only_one_result option. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the name of the facet for use in the URL. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the use_hierarchy. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the weight of the facet. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Sets the facet widget definition. Overrides FacetInterface:: |
|
Facet:: |
public | function |
Remove the facet lazy built data when the facet is serialized. Overrides ConfigEntityBase:: |
|
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | 1 |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. | 1 |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. | 1 |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
SynchronizableEntityTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
public | function |