You are here

public function NumberFieldBoost::submitConfigurationForm in Search API 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the complete form.

Overrides PluginFormTrait::submitConfigurationForm

See also

\Drupal\Core\Plugin\PluginFormInterface::submitConfigurationForm()

File

src/Plugin/search_api/processor/NumberFieldBoost.php, line 97

Class

NumberFieldBoost
Adds a boost based on a number field value.

Namespace

Drupal\search_api\Plugin\search_api\processor

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $ignore = Utility::formatBoostFactor(0);
  foreach ($values['boosts'] as $field_id => $settings) {
    if (!$settings['boost_factor'] || $settings['boost_factor'] === $ignore) {
      unset($values['boosts'][$field_id]);
    }
  }
  $form_state
    ->setValues($values);
  $this
    ->setConfiguration($values);
}