public function FacetapiAdapter::getFacetSettingsGlobal in Facet API 7
Same name and namespace in other branches
- 6.3 plugins/facetapi/adapter.inc \FacetapiAdapter::getFacetSettingsGlobal()
- 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter::getFacetSettingsGlobal()
Returns global settings for a facet.
Global settings are usually things that are processed by the backend such as the hard limit or query type. It isn't practical to execute separate search queries per realm to make these settings realm specific, so they are configured globally and reflected across all realms for this searcher.
Parameters
array $facet: The facet definition as returned by facetapi_facet_load().
Return value
An object containing the settings.
See also
File
- plugins/
facetapi/ adapter.inc, line 838 - Adapter plugin and adapter related classes.
Class
- FacetapiAdapter
- Abstract class extended by Facet API adapters.
Code
public function getFacetSettingsGlobal(array $facet) {
// Build the unique name of the configuration and check whether the setting
// has already be loaded so defaults are processed only once per setting.
$name = $this->info['name'] . '::' . $facet['name'];
if (!isset($this->settings[$name])) {
// Initialize settings and flag whether it is "new" meaning that all
// setting defaults are used.
$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,
'individual_parent' => 0,
'query_type' => $default_query_type,
);
// Apply the adapter's default settings.
$this->settings[$name]->settings += $this
->getDefaultSettings();
// Apply the URL processor's default settings.
$this->settings[$name]->settings += $this
->getUrlProcessor()
->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];
}