You are here

protected function SarniaSolrService::getFilteredFields in Sarnia 7

4 calls to SarniaSolrService::getFilteredFields()
SarniaSolrService::getDisplayFields in ./service.inc
SarniaSolrService::getFilterFields in ./service.inc
SarniaSolrService::getFulltextFields in ./service.inc
SarniaSolrService::getSortFields in ./service.inc

File

./service.inc, line 234

Class

SarniaSolrService
Search service class using Solr server.

Code

protected function getFilteredFields($filter, $reset = FALSE) {

  // If the data hasn't been retrieved before and we aren't refreshing it, try
  // to get data from the cache.
  $cid = "search_api_solr:fields:{$this->server->machine_name}:{$filter}";
  if (!isset($this->filteredFields[$filter]) && !$reset) {
    $cache = cache_get($cid);
    if (isset($cache->data)) {
      $this->filteredFields[$filter] = $cache->data;
    }
  }

  // If there was no data in the cache, or if we're refreshing the data,
  // filter the fields.
  if (!isset($this->filteredFields[$filter]) || $reset) {
    $this->filteredFields[$filter] = $this
      ->_getFilteredFields($filter, $reset);

    // Apply Sarnia transformations, which should be customized to match
    // specific schema.xml files.
    $this
      ->schemaApplyRules($this->filteredFields[$filter], $filter);
    drupal_alter('sarnia_solr_service_filter_fields', $this->filteredFields[$filter], $filter, $this);

    // Cache the filtered array.
    cache_set($cid, $this->filteredFields[$filter]);
  }
  return $this->filteredFields[$filter];
}