You are here

protected function SearchApiElasticsearchBackend::parseOptionFormElement in Elasticsearch Connector 8

Helper function. Parse an option form element.

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 235
Contains the SearchApiElasticsearchBackend object.

Class

SearchApiElasticsearchBackend
Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

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