You are here

class FacetapiQueryType in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 plugins/facetapi/query_type.inc \FacetapiQueryType
  2. 7 plugins/facetapi/query_type.inc \FacetapiQueryType

Base class for query type plugins.

Hierarchy

Expanded class hierarchy of FacetapiQueryType

File

plugins/facetapi/query_type.inc, line 98
Interfaces and base classes for query type plugins.

View source
class FacetapiQueryType {

  /**
   * The adapter associated with facet being queried.
   *
   * @var FacetapiAdapter
   */
  protected $adapter;

  /**
   * The facet definition as returned by facetapi_facet_load().
   *
   * @var array
   */
  protected $facet;

  /**
   * Constructs a FacetapiQueryType object.
   *
   * @param FacetapiAdapter $adapter
   *   The adapter object associated with facet being queried.
   * @param array $facet
   *   The facet definition as returned by facetapi_facet_load().
   */
  public function __construct(FacetapiAdapter $adapter, array $facet) {
    $this->adapter = $adapter;
    $this->facet = $facet;
  }

  /**
   * Adds additional information to the array active items.
   *
   * Active facet items are stored in the FacetapiAdapter::activeItems property
   * as associative arrays. See the docblock for the structure. Queries such as
   * ranges can add additional info such as the "start" and "end" values for
   * more efficient processing of facet data.
   *
   * @param array $item
   *   The active item. See FacetapiAdapter::activeItems for the structure of
   *   the active item array.
   *
   * @return array
   *   An associative array addition information to add to the active item.
   */
  public function extract(array $item) {
    return array();
  }

  /**
   * Convenience method to get the facet's global and per realm settings.
   *
   * @param string|array $realm
   *   The machine readable name of the realm or an array containing the realm
   *   definition. Pass NULL to return the facet's global settings.
   *
   * @return stdClass
   *   An object containing the settings.
   *
   * @see FacetapiFacet::getSettings()
   */
  public function getSettings($realm = NULL) {
    return $this->adapter
      ->getFacet($this->facet)
      ->getSettings($realm);
  }

  /**
   * Returns the facet's active items.
   *
   * @return array
   *   The facet's active items. See FacetapiAdapter::activeItems for the
   *   structure of the active item array.
   *
   * @see FacetapiAdapter::activeItems
   */
  public function getActiveItems() {
    return $this->adapter
      ->getActiveItems($this->facet);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FacetapiQueryType::$adapter protected property The adapter associated with facet being queried.
FacetapiQueryType::$facet protected property The facet definition as returned by facetapi_facet_load().
FacetapiQueryType::extract public function Adds additional information to the array active items. 2
FacetapiQueryType::getActiveItems public function Returns the facet's active items.
FacetapiQueryType::getSettings public function Convenience method to get the facet's global and per realm settings.
FacetapiQueryType::__construct public function Constructs a FacetapiQueryType object. 1