You are here

public function ImageAPIOptimizeProcessorFormBase::submitForm in Image Optimize (or ImageAPI Optimize) 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/ImageAPIOptimizeProcessorFormBase.php \Drupal\imageapi_optimize\Form\ImageAPIOptimizeProcessorFormBase::submitForm()
  2. 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\Form

Code

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