You are here

protected function SearchApiAlterAddAggregation::flattenArray in Search API 7

Helper method for flattening a multi-dimensional array.

1 call to SearchApiAlterAddAggregation::flattenArray()
SearchApiAlterAddAggregation::alterItems in includes/callback_add_aggregation.inc
Alter items before indexing.

File

includes/callback_add_aggregation.inc, line 255
Contains SearchApiAlterAddAggregation.

Class

SearchApiAlterAddAggregation
Search API data alteration callback that adds an URL field for all items.

Code

protected function flattenArray(array $data) {
  $ret = array();
  foreach ($data as $item) {
    if (!isset($item)) {
      continue;
    }
    if (is_scalar($item)) {
      $ret[] = $item;
    }
    else {
      $ret = array_merge($ret, $this
        ->flattenArray($item));
    }
  }
  return $ret;
}