You are here

public function ImageEffectFormBase::submitForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/image/src/Form/ImageEffectFormBase.php \Drupal\image\Form\ImageEffectFormBase::submitForm()
  2. 9 core/modules/image/src/Form/ImageEffectFormBase.php \Drupal\image\Form\ImageEffectFormBase::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

core/modules/image/src/Form/ImageEffectFormBase.php, line 117

Class

ImageEffectFormBase
Provides a base form for image effects.

Namespace

Drupal\image\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_state
    ->cleanValues();

  // The image effect configuration is stored in the 'data' key in the form,
  // pass that through for submission.
  $this->imageEffect
    ->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state));
  $this->imageEffect
    ->setWeight($form_state
    ->getValue('weight'));
  if (!$this->imageEffect
    ->getUuid()) {
    $this->imageStyle
      ->addImageEffect($this->imageEffect
      ->getConfiguration());
  }
  $this->imageStyle
    ->save();
  $this
    ->messenger()
    ->addStatus($this
    ->t('The image effect was successfully applied.'));
  $form_state
    ->setRedirectUrl($this->imageStyle
    ->toUrl('edit-form'));
}