public function ImageAPIOptimizeProcessorFormBase::submitForm in Image Optimize (or ImageAPI Optimize) 8.3
Same name and namespace in other branches
- 8.2 src/Form/ImageAPIOptimizeProcessorFormBase.php \Drupal\imageapi_optimize\Form\ImageAPIOptimizeProcessorFormBase::submitForm()
- 4.x src/Form/ImageAPIOptimizeProcessorFormBase.php \Drupal\imageapi_optimize\Form\ImageAPIOptimizeProcessorFormBase::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ ImageAPIOptimizeProcessorFormBase.php, line 113
Class
- ImageAPIOptimizeProcessorFormBase
- Provides a base form for image optimize processors.
Namespace
Drupal\imageapi_optimize\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->cleanValues();
// The image optimize processor configuration is stored in the 'data' key in the form,
// pass that through for submission.
$this->imageAPIOptimizeProcessor
->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state));
$this->imageAPIOptimizeProcessor
->setWeight($form_state
->getValue('weight'));
if (!$this->imageAPIOptimizeProcessor
->getUuid()) {
$this->imageAPIOptimizePipeline
->addProcessor($this->imageAPIOptimizeProcessor
->getConfiguration());
}
$this->imageAPIOptimizePipeline
->save();
$this
->messenger()
->addMessage($this
->t('The Image Optimize processor was successfully applied.'));
$form_state
->setRedirectUrl($this->imageAPIOptimizePipeline
->toUrl('edit-form'));
}