You are here

interface FacetInterface in Facets 8

The facet entity.

Hierarchy

Expanded class hierarchy of FacetInterface

All classes that implement FacetInterface

54 files declare their use of FacetInterface
ArrayWidget.php in src/Plugin/facets/widget/ArrayWidget.php
BooleanItemProcessor.php in src/Plugin/facets/processor/BooleanItemProcessor.php
BuildProcessorInterface.php in src/Processor/BuildProcessorInterface.php
CountLimitProcessor.php in src/Plugin/facets/processor/CountLimitProcessor.php
CustomWidget.php in tests/facets_custom_widget/src/Plugin/facets/widget/CustomWidget.php

... See full list

File

src/FacetInterface.php, line 10

Namespace

Drupal\facets
View source
interface FacetInterface extends ConfigEntityInterface {

  /**
   * Sets the facet widget definition.
   *
   * @param string $id
   *   The widget plugin id.
   * @param array $configuration
   *   (optional) The facet widget plugin configuration. If missed, the default
   *   plugin configuration will be filled.
   */
  public function setWidget($id, array $configuration = NULL);

  /**
   * Returns the facet widget definition.
   *
   * @return array
   *   An associative array with the following structure:
   *   - id: The widget plugin id as a string.
   *   - config: The widget configuration as an array.
   */
  public function getWidget();

  /**
   * Returns the facet widget instance.
   *
   * @return \Drupal\facets\Widget\WidgetPluginBase
   *   The plugin instance
   */
  public function getWidgetInstance();

  /**
   * Sets the facet hierarchy definition.
   *
   * @param string $id
   *   The hierarchy plugin id.
   * @param array $configuration
   *   (optional) The facet hierarchy plugin configuration. When empty, the
   *   default plugin configuration will be used.
   */
  public function setHierarchy($id, array $configuration = NULL);

  /**
   * Returns the facet hierarchy definition.
   *
   * @return array
   *   An associative array with the following structure:
   *   - id: The hierarchy plugin id as a string.
   *   - config: The widget configuration as an array.
   */
  public function getHierarchy();

  /**
   * Returns the facet hierarchy instance.
   *
   * @return \Drupal\facets\Hierarchy\HierarchyPluginBase
   *   The plugin instance
   */
  public function getHierarchyInstance();

  /**
   * Returns field identifier.
   *
   * @return string
   *   The field identifier of this facet.
   */
  public function getFieldIdentifier();

  /**
   * Sets field identifier.
   *
   * @param string $field_identifier
   *   The field identifier of this facet.
   */
  public function setFieldIdentifier($field_identifier);

  /**
   * Returns the field alias used to identify the facet in the url.
   *
   * @return string
   *   The field alias for the facet.
   */
  public function getFieldAlias();

  /**
   * Returns the field name of the facet as used in the index.
   *
   * @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 string $value
   *   An item that is active.
   */
  public function setActiveItem($value);

  /**
   * Returns all the active items in the facet.
   *
   * @return mixed
   *   An array containing all active items.
   */
  public function getActiveItems();

  /**
   * Overwrites the active items.
   *
   * @param array $values
   *   A list of values.
   */
  public function setActiveItems(array $values);

  /**
   * Checks if a value is active.
   *
   * @param string $value
   *   The value to be checked.
   *
   * @return bool
   *   Is an active value.
   */
  public function isActiveValue($value);

  /**
   * Returns the show_only_one_result option.
   *
   * @return bool
   *   Show only one result.
   */
  public function getShowOnlyOneResult();

  /**
   * Sets the show_only_one_result option.
   *
   * @param bool $show_only_one_result
   *   Show only one result.
   */
  public function setShowOnlyOneResult($show_only_one_result);

  /**
   * Returns the result for the facet.
   *
   * @return \Drupal\facets\Result\ResultInterface[]
   *   The results of the facet.
   */
  public function getResults();

  /**
   * Sets the results for the facet.
   *
   * @param \Drupal\facets\Result\ResultInterface[] $results
   *   The results of the facet.
   */
  public function setResults(array $results);

  /**
   * Returns the query type instance.
   *
   * @return string
   *   The query type plugin being used.
   */
  public function getQueryType();

  /**
   * Returns the query operator.
   *
   * @return string
   *   The query operator being used.
   */
  public function getQueryOperator();

  /**
   * Returns the limit number for facet items.
   */
  public function getHardLimit();

  /**
   * Returns the data definition from the facet field.
   *
   * @return \Drupal\Core\TypedData\DataDefinitionInterface
   *   A typed data definition.
   */
  public function getDataDefinition();

  /**
   * Returns the value of the exclude boolean.
   *
   * 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 bool
   *   A boolean flag indicating if search should exlude selected facets
   */
  public function getExclude();

  /**
   * Returns the value of the use_hierarchy boolean.
   *
   * This will return true when the results in the facet should be rendered in
   * a hierarchical structure.
   *
   * @return bool
   *   A boolean flag indicating if results should be rendered using hierarchy.
   */
  public function getUseHierarchy();

  /**
   * Sets the use_hierarchy.
   *
   * @param bool $use_hierarchy
   *   A boolean flag indicating if results should be rendered using hierarchy.
   */
  public function setUseHierarchy($use_hierarchy);

  /**
   * Returns the value of the keep_hierarchy_parents_active boolean.
   *
   * This will return true when the parent results of a hierarchical facet
   * should be kept active when a child becomes active.
   *
   * @return bool
   *   A boolean flag indicating if the parent results of a hierarchical facet
   *   should be kept active when a child becomes active.
   */
  public function getKeepHierarchyParentsActive();

  /**
   * Sets the keep_hierarchy_parents_active.
   *
   * @param bool $keep_hierarchy_parents_active
   *   A boolean flag indicating if the parent results of a hierarchical facet
   *   should be kept active when a child becomes active.
   */
  public function setKeepHierarchyParentsActive($keep_hierarchy_parents_active);

  /**
   * Returns the value of the expand_hierarchy boolean.
   *
   * This will return true when the results in the facet should be expanded in
   * a hierarchical structure, regardless of active state.
   *
   * @return bool
   *   Wether or not results should always be expanded using hierarchy.
   */
  public function getExpandHierarchy();

  /**
   * Sets the expand_hierarchy.
   *
   * @param bool $expand_hierarchy
   *   Wether or not results should always be expanded using hierarchy.
   */
  public function setExpandHierarchy($expand_hierarchy);

  /**
   * Returns the value of the enable_parent_when_child_gets_disabled boolean.
   *
   * This will return true when the parent item in the facet should be enabled
   * in an hierarchical structure, when a child facet item gets disabled.
   *
   * @return bool
   *   Wether or not parents should be enabled when a child gets disabled.
   */
  public function getEnableParentWhenChildGetsDisabled();

  /**
   * Sets the enable_parent_when_child_gets_disabled.
   *
   * @param bool $enable_parent_when_child_gets_disabled
   *   Wether or not parents should be enabled when a child gets disabled.
   */
  public function setEnableParentWhenChildGetsDisabled($enable_parent_when_child_gets_disabled);

  /**
   * Sets a string representation of the Facet source plugin.
   *
   * This is usually the name of the Search-api view.
   *
   * @param string $facet_source_id
   *   The facet source id.
   */
  public function setFacetSourceId($facet_source_id);

  /**
   * Sets the query operator.
   *
   * @param string $operator
   *   The query operator being used.
   */
  public function setQueryOperator($operator);

  /**
   * Sets the hard limit of facet items.
   *
   * @param int $limit
   *   Hard limit of the facet.
   */
  public function setHardLimit($limit);

  /**
   * 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\facets\FacetSource\FacetSourcePluginInterface|null
   *   The plugin instance for the facet source.
   */
  public function getFacetSource();

  /**
   * Returns the facet source configuration object.
   *
   * @return \Drupal\facets\FacetSourceInterface
   *   A facet source configuration object.
   */
  public function getFacetSourceConfig();

  /**
   * Loads the facet sources for this facet.
   *
   * @param bool $only_enabled
   *   Only return enabled facet sources.
   *
   * @return \Drupal\facets\FacetSource\FacetSourcePluginInterface[]
   *   An array of facet sources.
   */
  public function getFacetSources($only_enabled = TRUE);

  /**
   * Returns an array of processors with their configuration.
   *
   * @param bool $only_enabled
   *   Only return enabled processors.
   *
   * @return \Drupal\facets\Processor\ProcessorInterface[]
   *   An array of processors.
   */
  public function getProcessors($only_enabled = TRUE);

  /**
   * Loads this facets processors for a specific stage.
   *
   * @param string $stage
   *   The stage for which to return the processors. One of the
   *   \Drupal\facets\Processor\ProcessorInterface::STAGE_* constants.
   * @param bool $only_enabled
   *   (optional) If FALSE, also include disabled processors. Otherwise, only
   *   load enabled ones.
   *
   * @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.
   *
   * @param bool $only_visible_when_facet_source_is_visible
   *   A boolean flag indicating if the facet should be hidden on a page that
   *   does not show the facet source.
   */
  public function setOnlyVisibleWhenFacetSourceIsVisible($only_visible_when_facet_source_is_visible);

  /**
   * Returns the "only visible when facet source is visible" boolean flag.
   *
   * @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 weight of the facet.
   */
  public function getWeight();

  /**
   * Sets the weight of the facet.
   *
   * @param int $weight
   *   Weight of the facet.
   */
  public function setWeight($weight);

  /**
   * Sets the minimum count of the result to show.
   *
   * @param int $min_count
   *   Minimum count.
   */
  public function setMinCount($min_count);

  /**
   * Returns the minimum count of the result to show.
   *
   * @return int
   *   Minimum count.
   */
  public function getMinCount();

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 9
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. 34
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. 34
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 27
ConfigEntityInterface::calculateDependencies public function Calculates dependencies and stores them in the dependency property. 2
ConfigEntityInterface::disable public function Disables the configuration entity. 2
ConfigEntityInterface::enable public function Enables the configuration entity. 2
ConfigEntityInterface::get public function Returns the value of a property. 2
ConfigEntityInterface::getDependencies public function Gets the configuration dependencies. 2
ConfigEntityInterface::hasTrustedData public function Gets whether on not the data is trusted. 2
ConfigEntityInterface::isInstallable public function Checks whether this entity is installable. 2
ConfigEntityInterface::isUninstalling public function Returns whether this entity is being changed during the uninstall process. 2
ConfigEntityInterface::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. 2
ConfigEntityInterface::set public function Sets the value of a property. 2
ConfigEntityInterface::setStatus public function Sets the status of the configuration entity. 2
ConfigEntityInterface::status public function Returns whether the configuration entity is enabled. 2
ConfigEntityInterface::trustData public function Sets that the data should be trusted. 2
EntityInterface::bundle public function Gets the bundle of the entity. 2
EntityInterface::create public static function Constructs a new entity object, without permanently saving it. 2
EntityInterface::createDuplicate public function Creates a duplicate of the entity. 2
EntityInterface::delete public function Deletes an entity permanently. 2
EntityInterface::enforceIsNew public function Enforces an entity to be new. 2
EntityInterface::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. 2
EntityInterface::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. 2
EntityInterface::getConfigDependencyName public function Gets the configuration dependency name. 2
EntityInterface::getConfigTarget public function Gets the configuration target identifier for the entity. 2
EntityInterface::getEntityType public function Gets the entity type definition. 2
EntityInterface::getEntityTypeId public function Gets the ID of the type of the entity. 2
EntityInterface::getOriginalId public function Gets the original ID. 2
EntityInterface::getTypedData public function Gets a typed data object for this entity object. 2
EntityInterface::hasLinkTemplate public function Indicates if a link template exists for a given key. 2
EntityInterface::id public function Gets the identifier. 2
EntityInterface::isNew public function Determines whether the entity is new. 2
EntityInterface::label public function Gets the label of the entity. 2
EntityInterface::language public function Gets the language of the entity. 2
EntityInterface::link Deprecated public function Deprecated way of generating a link to the entity. See toLink(). 2
EntityInterface::load public static function Loads an entity. 2
EntityInterface::loadMultiple public static function Loads one or more entities. 2
EntityInterface::postCreate public function Acts on a created entity before hooks are invoked. 2
EntityInterface::postDelete public static function Acts on deleted entities before the delete hook is invoked. 2
EntityInterface::postLoad public static function Acts on loaded entities. 3
EntityInterface::postSave public function Acts on a saved entity before the insert or update hook is invoked. 2
EntityInterface::preCreate public static function Changes the values of an entity before it is created. 2
EntityInterface::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. 2
EntityInterface::preSave public function Acts on an entity before the presave hook is invoked. 2
EntityInterface::referencedEntities public function Gets a list of entities referenced by this entity. 2
EntityInterface::save public function Saves an entity permanently. 2
EntityInterface::setOriginalId public function Sets the original ID. 2
EntityInterface::toArray public function Gets an array of all property values. 3
EntityInterface::toLink public function Generates the HTML for a link to this entity. 2
EntityInterface::toUrl public function Gets the URL object for the entity. 2
EntityInterface::uriRelationships public function Gets a list of URI relationships supported by this entity. 2
EntityInterface::url Deprecated public function Gets the public URL for this entity. 2
EntityInterface::urlInfo Deprecated public function Gets the URL object for the entity. 2
EntityInterface::uuid public function Gets the entity UUID (Universally Unique Identifier). 2
FacetInterface::addProcessor public function Adds a processor for this facet. 1
FacetInterface::getActiveItems public function Returns all the active items in the facet. 1
FacetInterface::getDataDefinition public function Returns the data definition from the facet field. 1
FacetInterface::getEmptyBehavior public function Returns the defined no-results behavior or NULL if none defined. 1
FacetInterface::getEnableParentWhenChildGetsDisabled public function Returns the value of the enable_parent_when_child_gets_disabled boolean. 1
FacetInterface::getExclude public function Returns the value of the exclude boolean. 1
FacetInterface::getExpandHierarchy public function Returns the value of the expand_hierarchy boolean. 1
FacetInterface::getFacetSource public function Returns the plugin instance of a facet source. 1
FacetInterface::getFacetSourceConfig public function Returns the facet source configuration object. 1
FacetInterface::getFacetSourceId public function Returns the Facet source id. 1
FacetInterface::getFacetSources public function Loads the facet sources for this facet. 1
FacetInterface::getFieldAlias public function Returns the field alias used to identify the facet in the url. 1
FacetInterface::getFieldIdentifier public function Returns field identifier. 1
FacetInterface::getHardLimit public function Returns the limit number for facet items. 1
FacetInterface::getHierarchy public function Returns the facet hierarchy definition. 1
FacetInterface::getHierarchyInstance public function Returns the facet hierarchy instance. 1
FacetInterface::getKeepHierarchyParentsActive public function Returns the value of the keep_hierarchy_parents_active boolean. 1
FacetInterface::getMinCount public function Returns the minimum count of the result to show. 1
FacetInterface::getName public function Returns the field name of the facet as used in the index. 1
FacetInterface::getOnlyVisibleWhenFacetSourceIsVisible public function Returns the "only visible when facet source is visible" boolean flag. 1
FacetInterface::getProcessorConfigs public function Retrieves this facets's processor configs. 1
FacetInterface::getProcessors public function Returns an array of processors with their configuration. 1
FacetInterface::getProcessorsByStage public function Loads this facets processors for a specific stage. 1
FacetInterface::getQueryOperator public function Returns the query operator. 1
FacetInterface::getQueryType public function Returns the query type instance. 1
FacetInterface::getResults public function Returns the result for the facet. 1
FacetInterface::getShowOnlyOneResult public function Returns the show_only_one_result option. 1
FacetInterface::getUrlAlias public function Returns the name of the facet for use in the URL. 1
FacetInterface::getUseHierarchy public function Returns the value of the use_hierarchy boolean. 1
FacetInterface::getWeight public function Returns the weight of the facet. 1
FacetInterface::getWidget public function Returns the facet widget definition. 1
FacetInterface::getWidgetInstance public function Returns the facet widget instance. 1
FacetInterface::isActiveValue public function Checks if a value is active. 1
FacetInterface::removeProcessor public function Removes a processor for this facet. 1
FacetInterface::setActiveItem public function Sets an item with value to active. 1
FacetInterface::setActiveItems public function Overwrites the active items. 1
FacetInterface::setEmptyBehavior public function Defines the no-results behavior. 1
FacetInterface::setEnableParentWhenChildGetsDisabled public function Sets the enable_parent_when_child_gets_disabled. 1
FacetInterface::setExclude public function Sets the exclude. 1
FacetInterface::setExpandHierarchy public function Sets the expand_hierarchy. 1
FacetInterface::setFacetSourceId public function Sets a string representation of the Facet source plugin. 1
FacetInterface::setFieldIdentifier public function Sets field identifier. 1
FacetInterface::setHardLimit public function Sets the hard limit of facet items. 1
FacetInterface::setHierarchy public function Sets the facet hierarchy definition. 1
FacetInterface::setKeepHierarchyParentsActive public function Sets the keep_hierarchy_parents_active. 1
FacetInterface::setMinCount public function Sets the minimum count of the result to show. 1
FacetInterface::setOnlyVisibleWhenFacetSourceIsVisible public function Sets the "only visible when facet source is visible" boolean flag. 1
FacetInterface::setQueryOperator public function Sets the query operator. 1
FacetInterface::setResults public function Sets the results for the facet. 1
FacetInterface::setShowOnlyOneResult public function Sets the show_only_one_result option. 1
FacetInterface::setUrlAlias public function Sets the name of the facet for use in the URL. 1
FacetInterface::setUseHierarchy public function Sets the use_hierarchy. 1
FacetInterface::setWeight public function Sets the weight of the facet. 1
FacetInterface::setWidget public function Sets the facet widget definition. 1
RefinableCacheableDependencyInterface::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. 1
RefinableCacheableDependencyInterface::addCacheContexts public function Adds cache contexts. 1
RefinableCacheableDependencyInterface::addCacheTags public function Adds cache tags. 1
RefinableCacheableDependencyInterface::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. 1
SynchronizableInterface::isSyncing public function Returns whether this entity is being changed as part of a synchronization. 1
SynchronizableInterface::setSyncing public function Sets the status of the synchronization flag. 1
ThirdPartySettingsInterface::getThirdPartyProviders public function Gets the list of third parties that store information. 5
ThirdPartySettingsInterface::getThirdPartySetting public function Gets the value of a third-party setting. 5
ThirdPartySettingsInterface::getThirdPartySettings public function Gets all third-party settings of a given module. 5
ThirdPartySettingsInterface::setThirdPartySetting public function Sets the value of a third-party setting. 5
ThirdPartySettingsInterface::unsetThirdPartySetting public function Unsets a third-party setting. 5