/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $new_settings = array(); // Store processor settings. // @todo Go through all available processors, enable/disable with method on // processor plugin to allow reaction. /** @var \Drupal\search_api\Processor\ProcessorInterface $processor */ $processors = $this->entity->getProcessors(FALSE); foreach ($processors as $processor_id => $processor) { if (empty($values['status'][$processor_id])) { continue; } $new_settings[$processor_id] = array('processor_id' => $processor_id, 'weights' => array(), 'settings' => array()); $processor_values = $values['processors'][$processor_id]; if (!empty($processor_values['weights'])) { $new_settings[$processor_id]['weights'] = $processor_values['weights']; } if (isset($form['settings'][$processor_id])) { $processor_form_state = new SubFormState($form_state, array('processors', $processor_id, 'settings')); $processor->submitConfigurationForm($form['settings'][$processor_id], $processor_form_state); $new_settings[$processor_id]['settings'] = $processor->getConfiguration(); } } // Sort the processors so we won't have unnecessary changes. ksort($new_settings); if (!$this->entity->getOption('processors', array()) !== $new_settings) { $this->entity->setOption('processors', $new_settings); $this->entity->save(); $this->entity->reindex(); drupal_set_message($this->t('The indexing workflow was successfully edited. All content was scheduled for reindexing so the new settings can take effect.')); } else { drupal_set_message($this->t('No values were changed.')); } }
/** * {@inheritdoc} */ public function updateIndex(IndexInterface $index) { $this->checkError(__FUNCTION__); $index->reindex(); }
/** * {@inheritdoc} */ public function reindex() { return $this->entity->reindex(); }