You are here

abstract class FacetapiUrlProcessor in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 plugins/facetapi/url_processor.inc \FacetapiUrlProcessor
  2. 7 plugins/facetapi/url_processor.inc \FacetapiUrlProcessor

Hierarchy

Expanded class hierarchy of FacetapiUrlProcessor

1 string reference to 'FacetapiUrlProcessor'
facetapi_facetapi_url_processors in ./facetapi.facetapi.inc
Implements hook_facetapi_url_processors().

File

plugins/facetapi/url_processor.inc, line 11
Adapter and standard plugin class.

View source
abstract class FacetapiUrlProcessor {

  /**
   * The adapter.
   *
   * @var FacetapiAdapter
   */
  protected $adapter;

  /**
   * An array of facet params.
   *
   * @var array.
   */
  protected $params = array();

  /**
   * The key containing the facet filters.
   *
   * @var string
   */
  protected $filterKey = 'f';

  /**
   *
   */
  public function __construct(FacetapiAdapter $adapter) {
    $this->adapter = $adapter;
  }

  /**
   * Automatically fetches the params when the plugin is instantiated.
   *
   * @return array
   *   An array containing the params.
   */
  public abstract function fetchParams();

  /**
   * Normalizes the array returned by FacetapiAdapter::fetchParams().
   *
   * @param array $params
   *   An array of keyed params, such as $_GET.
   * @param string $filter_key
   *   The array key in $params corresponding to filters.
   *
   * @return array
   *   An array containing the normalized params.
   */
  public abstract function normalizeParams(array $params, $filter_key = 'f');

  /**
   * Returns the query string variables for a facet item.
   *
   * @param array $facet
   *   The facet definition.
   * @param array $values
   *   An array containing the item's values being added to or removed from the
   *   query string dependent on whether or not the item is active.
   * @param int $active
   *   An integer flagging whether the item is active or not.
   *
   * @return array
   *   The query string vriables.
   */
  public abstract function getQueryString(array $facet, array $values, $active);

  /**
   * Returns the path for a facet item.
   *
   * @param array $facet
   *   The facet definition.
   * @param array $values
   *   An array containing the item's values being added to or removed from the
   *   query string dependent on whether or not the item is active.
   * @param int $active
   *   An integer flagging whether the item is active or not.
   *
   * @return string
   *   The path of the facet.
   */
  public function getFacetPath(array $facet, array $values, $active) {
    return $this->adapter
      ->getSearchPath();
  }

  /**
   * Sets the breadcrumb trail on searches.
   */
  public abstract function setBreadcrumb();

  /**
   * Sets the parameters.
   *
   * @param array $params
   *   An array of normalized params.
   * @param string $filter_key
   *   The array key in $params corresponding to filters.
   *
   * @return FacetapiUrlParser
   *   An instance of this class.
   */
  public function setParams(array $params, $filter_key = 'f') {
    $this->params = $params;
    $this->filterKey = $filter_key;
    if (!isset($this->params[$this->filterKey]) || !is_array($this->params[$this->filterKey])) {
      $this->params[$this->filterKey] = array();
    }
    return $this;
  }

  /**
   * Returns the params.
   *
   * @return array
   *   An array containing the params.
   */
  public function getParams() {
    return $this->params;
  }

  /**
   * Removes an item from the $this->params array.
   */
  public function removeParam($pos) {
    unset($this->params[$this->filterKey][$pos]);
  }

  /**
   * Returns the filter key.
   *
   * @return string
   *   A string containing the filter key.
   */
  public function getFilterKey() {
    return $this->filterKey;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FacetapiUrlProcessor::$adapter protected property The adapter.
FacetapiUrlProcessor::$filterKey protected property The key containing the facet filters.
FacetapiUrlProcessor::$params protected property An array of facet params.
FacetapiUrlProcessor::fetchParams abstract public function Automatically fetches the params when the plugin is instantiated. 1
FacetapiUrlProcessor::getFacetPath public function Returns the path for a facet item.
FacetapiUrlProcessor::getFilterKey public function Returns the filter key.
FacetapiUrlProcessor::getParams public function Returns the params.
FacetapiUrlProcessor::getQueryString abstract public function Returns the query string variables for a facet item. 1
FacetapiUrlProcessor::normalizeParams abstract public function Normalizes the array returned by FacetapiAdapter::fetchParams(). 1
FacetapiUrlProcessor::removeParam public function Removes an item from the $this->params array.
FacetapiUrlProcessor::setBreadcrumb abstract public function Sets the breadcrumb trail on searches. 1
FacetapiUrlProcessor::setParams public function Sets the parameters.
FacetapiUrlProcessor::__construct public function