function FacetapiWidget::sortFacet in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/widget.inc \FacetapiWidget::sortFacet()
- 7 plugins/facetapi/widget.inc \FacetapiWidget::sortFacet()
Applies selected sorting algorithms to the render array.
Parameters
array &$build: The facet's render array.
1 call to FacetapiWidget::sortFacet()
- FacetapiWidget::init in plugins/
facetapi/ widget.inc - Initializes the build, must be invoked prior to executing this widget.
File
- plugins/
facetapi/ widget.inc, line 197 - Abstract widget plugin class.
Class
- FacetapiWidget
- Base class for widget plugins.
Code
function sortFacet(array &$build) {
$settings = $build['#settings']->settings;
// Gets active sort definitions.
$this->sorts = array_intersect_key(facetapi_get_sort_info(), array_filter($settings['active_sorts']));
// Finalizes sort definitions with settings or defaults.
foreach ($this->sorts as $name => &$info) {
$info['weight'] = $settings['sort_weight'][$name];
$info['order'] = $settings['sort_order'][$name];
}
if ($this->sorts) {
// Orders the sorts, applies sorting algorithms in that order.
uasort($this->sorts, 'facetapi_sort_weight');
$this
->applySorts($build[$this->facet['field alias']]);
}
}