function elasticsearch_connector_autocomp_form_search_api_index_form_submit in Elasticsearch Connector Autocomplete 8
Custom submit handler for search_api_index_form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 string reference to 'elasticsearch_connector_autocomp_form_search_api_index_form_submit'
File
- ./
elasticsearch_connector_autocomp.module, line 152 - Contains elasticsearch_connector_autocomp.module.
Code
function elasticsearch_connector_autocomp_form_search_api_index_form_submit(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\search_api\Form\IndexForm $formObject */
$formObject = $form_state
->getFormObject();
/** @var \Drupal\search_api\IndexInterface $index */
$index = $formObject
->getEntity();
$new_state = $index
->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE);
$new_state_config = $index
->getThirdPartySetting('elasticsearch_connector', 'ngram_config', FALSE);
$original = \Drupal::entityTypeManager()
->getStorage('search_api_index')
->loadUnchanged($index
->id());
if ($original) {
$current_state = $original
->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE);
$current_state_config = $original
->getThirdPartySetting('elasticsearch_connector', 'ngram_config', FALSE);
}
if ($form_state
->has('eca_confirm_form_values') && $form_state
->getValue('op') === 'Confirm') {
$form_state
->setValues($form_state
->get('eca_confirm_form_values'));
// Handle the actual submit.
$formObject
->submitForm($form, $form_state);
$formObject
->save($form, $form_state);
return;
}
if ($original) {
if ($new_state !== $current_state || $new_state_config !== $current_state_config) {
$form_state
->setRebuild();
$form_state
->set('eca_confirm_form_values', $form_state
->getValues());
return;
}
}
// No confirmation required, defer to the existing submit handlers.
$formObject
->submitForm($form, $form_state);
$formObject
->save($form, $form_state);
}