You are here

public function ImageEffectFormBase::submitForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 119
Contains \Drupal\image\Form\ImageEffectFormBase.

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.
  $effect_data = (new FormState())
    ->setValues($form_state
    ->getValue('data'));
  $this->imageEffect
    ->submitConfigurationForm($form, $effect_data);

  // Update the original form values.
  $form_state
    ->setValue('data', $effect_data
    ->getValues());
  $this->imageEffect
    ->setWeight($form_state
    ->getValue('weight'));
  if (!$this->imageEffect
    ->getUuid()) {
    $this->imageStyle
      ->addImageEffect($this->imageEffect
      ->getConfiguration());
  }
  $this->imageStyle
    ->save();
  drupal_set_message($this
    ->t('The image effect was successfully applied.'));
  $form_state
    ->setRedirectUrl($this->imageStyle
    ->urlInfo('edit-form'));
}