You are here

protected function SearchApiElasticsearchConnector::parseOptionFormElement in Elasticsearch Connector 7

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::parseOptionFormElement()
  2. 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::parseOptionFormElement()

Helper function. Parse an option form element.

1 call to SearchApiElasticsearchConnector::parseOptionFormElement()
SearchApiElasticsearchConnector::viewSettings in modules/elasticsearch_connector_search_api/service.inc
Overrides viewSettings().

File

modules/elasticsearch_connector_search_api/service.inc, line 217
Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.

Class

SearchApiElasticsearchConnector
Search service 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();
}