You are here

protected function FacetapiWidget::applySorts in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 plugins/facetapi/widget.inc \FacetapiWidget::applySorts()
  2. 7 plugins/facetapi/widget.inc \FacetapiWidget::applySorts()

Applies the sorts to the facet items recursively.

The recursion in this function is useful for sorting hierarchical data sets one level at a time.

Parameters

array &$build: Reference to the items in the facet's render array that are being sorted.

See also

FacetapiWidget::sortFacet()

FacetapiWidget::sortCallback()

1 call to FacetapiWidget::applySorts()
FacetapiWidget::sortFacet in plugins/facetapi/widget.inc
Applies sorting algorithms to the items in the facet's render array.

File

plugins/facetapi/widget.inc, line 300
Base widget plugin class and helper functions for facet sorting.

Class

FacetapiWidget
Abstract class extended by widget plugins.

Code

protected function applySorts(&$build) {
  foreach (element_children($build) as $value) {
    if (!empty($build[$value]['#item_children'])) {
      $this
        ->applySorts($build[$value]['#item_children']);
    }
  }

  // Uses FacetapiWidget::sortCallback() as the uasort() callback.
  uasort($build, array(
    $this,
    'sortCallback',
  ));
}