You are here

protected function SearchApiElasticsearchAbstractService::parseOptionFormElement in Search API Elasticsearch 7

Helper function. Parse an option form element.

1 call to SearchApiElasticsearchAbstractService::parseOptionFormElement()
SearchApiElasticsearchElastica::viewSettings in modules/elastica/includes/SearchApiElasticsearchElastica.inc
Overrides viewSettings().

File

includes/SearchApiElasticsearchAbstractService.inc, line 397
Provides a Elasticsearch-based service class for the Search API.

Class

SearchApiElasticsearchAbstractService
Elasticsearch service abstract class.

Code

protected function parseOptionFormElement($element, $key) {
  $children_keys = element_children($element);
  if (!empty($children_keys)) {
    $children = array();
    foreach ($children_keys as $child_key) {
      $child = $this
        ->parseOptionFormElement($element[$child_key], $child_key);
      if (!empty($child)) {
        $children[] = $child;
      }
    }
    if (!empty($children)) {
      return array(
        'label' => isset($element['#title']) ? $element['#title'] : $key,
        'option' => $children,
      );
    }
  }
  elseif (isset($this->options[$key])) {
    return array(
      'label' => isset($element['#title']) ? $element['#title'] : $key,
      'option' => $key,
    );
  }
  return array();
}