protected function FacetapiFacetProcessor::mapValues in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/adapter.inc \FacetapiFacetProcessor::mapValues()
- 7 plugins/facetapi/adapter.inc \FacetapiFacetProcessor::mapValues()
Maps the IDs to human readable values via the mapping callback.
Parameters
array $build: The initialized render array.
Return value
array The initialized render array with mapped values.
1 call to FacetapiFacetProcessor::mapValues()
- FacetapiFacetProcessor::process in plugins/
facetapi/ adapter.inc - Processes the facet items.
File
- plugins/
facetapi/ adapter.inc, line 1246 - Adapter plugin and adapter related calsses.
Class
- FacetapiFacetProcessor
- Processes facets, initializes the build.
Code
protected function mapValues(array $build) {
if ($this->facet['map callback']) {
// Gets available items and active items, runs through map callback only
// when there are values to map.
// NOTE: array_merge() doesn't work here when the values are numeric.
if ($values = array_unique(array_keys($build + $this
->getActiveItems()))) {
$this->map = call_user_func($this->facet['map callback'], $values, $this->facet['map options']);
// Normalize all mapped values to a two element array.
foreach ($this->map as $key => $value) {
if (!is_array($value)) {
$this->map[$key] = array();
$this->map[$key]['#value'] = $value;
$this->map[$key]['#html'] = FALSE;
}
if (isset($build[$key])) {
$build[$key]['#value'] = $this->map[$key]['#value'];
$build[$key]['#html'] = !empty($this->map[$key]['#html']);
}
}
}
}
return $build;
}