public function FacetapiUrlProcessorSession::fetchParams in Facet API Bonus 7
Implements FacetapiUrlProcessor::fetchParams().
Use $_GET as the source for facet data when available and fall back to $_SESSION, also storing the $_GET bits into the session.
File
- modules/
facetapi_bonus_session/ includes/ facetapi/ url_processor_session.inc, line 28 - A facet handler that falls back onto session set variables.
Class
- FacetapiUrlProcessorSession
- Url processor plugin that retrieves facet data from the query string.
Code
public function fetchParams() {
$return = parent::fetchParams();
// Get hold of our namespaced session variable.
$session =& $this
->getSession();
// Check if we need to update the session with a new request.
if (isset($_GET[$this->filterKey])) {
$session[$this->filterKey] = $_GET[$this->filterKey] == 'clear' ? array() : $_GET[$this->filterKey];
// Strip out any empty filters.
foreach ($session[$this->filterKey] as $i => $facet) {
$parts = explode(':', $facet);
if (empty($parts[1])) {
unset($session[$this->filterKey][$i]);
}
}
}
return array_merge($return, $session);
}