You are here

public function FacetapiAdapter::getFacetSettingsGlobal in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter::getFacetSettingsGlobal()
  2. 7 plugins/facetapi/adapter.inc \FacetapiAdapter::getFacetSettingsGlobal()

Returns realm specific settings for a facet.

Parameters

array $facet: An array containing the facet definition.

Return value

An object containing the settings.

See also

ctools_export_crud_load()

File

plugins/facetapi/adapter.inc, line 623
Adapter plugin and adapter related calsses.

Class

FacetapiAdapter
Abstract class extended by search backends that retrieves facet information from the database.

Code

public function getFacetSettingsGlobal(array $facet) {
  $name = $this->info['name'] . '::' . $facet['name'];
  if (!isset($this->settings[$name])) {
    $this->settings[$name] = $this
      ->initSettingsObject($name, $facet['name']);
    $is_new = empty($this->settings[$name]->settings);

    // Ensure the default operator and query type are valid.
    // @see http://drupal.org/node/1443340
    $default_query_type = reset($facet['query types']);
    $allowed_operators = array_filter($facet['allowed operators']);
    $default_operator = key($allowed_operators);

    // Apply defaults common across all configs.
    $this->settings[$name]->settings += array(
      'operator' => $default_operator,
      'hard_limit' => 50,
      'dependencies' => array(),
      'facet_mincount' => 1,
      'facet_missing' => 0,
      'flatten' => 0,
      'query_type' => $default_query_type,
    );

    // Apply the adapter's default settings.
    $this->settings[$name]->settings += $this
      ->getDefaultSettings();

    // Applies each dependency plugin's default settings.
    foreach ($facet['dependency plugins'] as $id) {
      if ($is_new) {
        $this->settings[$name]->settings['dependencies'] = array();
      }
      $class = ctools_plugin_load_class('facetapi', 'dependencies', $id, 'handler');
      $plugin = new $class($id, $this, $facet, $this->settings[$name], array());
      $this->settings[$name]->settings['dependencies'] += $plugin
        ->getDefaultSettings();
    }

    // @todo Save for performance?
  }
  return $this->settings[$name];
}