You are here

function apachesolr_views_query::remove_filter in Apache Solr Views 6

Remove a facet from the query

Parameters

string $field: the facet field to remove

string $value: The facet value to remove This value can be NULL

File

./apachesolr_views_query.inc, line 586

Class

apachesolr_views_query
Class for handling a view that gets its data not from the database, but from a Solr server.

Code

function remove_filter($field, $value = NULL) {
  if (!empty($value)) {
    if (isset($this->_facets[$field])) {
      $removal_key = FALSE;
      foreach ($this->_facets[$field] as $key => $definition) {
        if ($definition['value'] == $value) {
          $removal_key = $key;
          break;
        }
      }

      // we found it delete the value
      if ($removal_key !== FALSE) {
        unset($this->_facets[$field][$removal_key]);
      }
    }
  }
  else {
    if (isset($this->_facets[$field])) {
      unset($this->_facets[$field]);
    }
  }
}