function ImageStyleEditForm::effectSave
Same name in other branches
- 9 core/modules/image/src/Form/ImageStyleEditForm.php \Drupal\image\Form\ImageStyleEditForm::effectSave()
- 8.9.x core/modules/image/src/Form/ImageStyleEditForm.php \Drupal\image\Form\ImageStyleEditForm::effectSave()
- 11.x core/modules/image/src/Form/ImageStyleEditForm.php \Drupal\image\Form\ImageStyleEditForm::effectSave()
Submit handler for image effect.
File
-
core/
modules/ image/ src/ Form/ ImageStyleEditForm.php, line 207
Class
- ImageStyleEditForm
- Controller for image style edit form.
Namespace
Drupal\image\FormCode
public function effectSave($form, FormStateInterface $form_state) {
$this->save($form, $form_state);
// Check if this field has any configuration options.
$effect = $this->imageEffectManager
->getDefinition($form_state->getValue('new'));
// Load the configuration form for this option.
if (is_subclass_of($effect['class'], '\\Drupal\\image\\ConfigurableImageEffectInterface')) {
$form_state->setRedirect('image.effect_add_form', [
'image_style' => $this->entity
->id(),
'image_effect' => $form_state->getValue('new'),
], [
'query' => [
'weight' => $form_state->getValue('weight'),
],
]);
$form_state->setIgnoreDestination();
}
else {
$effect = [
'id' => $effect['id'],
'data' => [],
'weight' => $form_state->getValue('weight'),
];
$effect_id = $this->entity
->addImageEffect($effect);
$this->entity
->save();
if (!empty($effect_id)) {
$this->messenger()
->addStatus($this->t('The image effect was successfully applied.'));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.