You are here

public function CurrentSearchItem::getItemValues in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 contrib/current_search/plugins/current_search/item.inc \CurrentSearchItem::getItemValues()
  2. 7 contrib/current_search/plugins/current_search/item.inc \CurrentSearchItem::getItemValues()

Helper function that returns the item's value and its children.

Parameters

array $item: The item as returned by FacetapiAdapter::getAllActiveItems().

FacetapiAdapter $adapter: The adapter object of the current search.

Return value

array An array of the item's value and all its children.

2 calls to CurrentSearchItem::getItemValues()
CurrentSearchItem::getFacetPath in contrib/current_search/plugins/current_search/item.inc
Helper function that returns a facet's path.
CurrentSearchItem::getQueryString in contrib/current_search/plugins/current_search/item.inc
Helper function that returns a facet's query string.

File

contrib/current_search/plugins/current_search/item.inc, line 212
Current search plugin base class.

Class

CurrentSearchItem
Base class for current search item plugins.

Code

public function getItemValues(array $item, FacetapiAdapter $adapter) {
  if (!isset($this->itemValues[$item['pos']])) {

    // Initializes items, sets $values as a reference for code readability.
    $this->itemValues[$item['pos']] = array();
    $values =& $this->itemValues[$item['pos']];

    // Gets all children so they are deactivated as well.
    foreach ($item['facets'] as $facet_name) {
      $active_children = $adapter
        ->getProcessor($facet_name)
        ->getActiveChildren($item['value']);
      $values = array_merge($values, $active_children);
    }

    // Handle the case of a URL value that matches no actual facet values.
    // Otherwise, it can't be unclicked.
    if (!in_array($item['value'], $values)) {
      $values[] = $item['value'];
    }
  }
  return $this->itemValues[$item['pos']];
}