public function ImageAPIOptimizePipelineEditForm::processorSave in Image Optimize (or ImageAPI Optimize) 4.x
Same name and namespace in other branches
- 8.3 src/Form/ImageAPIOptimizePipelineEditForm.php \Drupal\imageapi_optimize\Form\ImageAPIOptimizePipelineEditForm::processorSave()
- 8.2 src/Form/ImageAPIOptimizePipelineEditForm.php \Drupal\imageapi_optimize\Form\ImageAPIOptimizePipelineEditForm::processorSave()
Submit handler for image optimize processor.
File
- src/
Form/ ImageAPIOptimizePipelineEditForm.php, line 194
Class
- ImageAPIOptimizePipelineEditForm
- Controller for image optimize pipeline edit form.
Namespace
Drupal\imageapi_optimize\FormCode
public function processorSave($form, FormStateInterface $form_state) {
$this
->save($form, $form_state);
// Check if this field has any configuration options.
$processor = $this->imageAPIOptimizeProcessorManager
->getDefinition($form_state
->getValue('new'));
// Load the configuration form for this option.
if (is_subclass_of($processor['class'], '\\Drupal\\imageapi_optimize\\ConfigurableImageAPIOptimizeProcessorInterface')) {
$form_state
->setRedirect('imageapi_optimize.processor_add_form', [
'imageapi_optimize_pipeline' => $this->entity
->id(),
'imageapi_optimize_processor' => $form_state
->getValue('new'),
], [
'query' => [
'weight' => $form_state
->getValue('weight'),
],
]);
}
else {
$processor = [
'id' => $processor['id'],
'data' => [],
'weight' => $form_state
->getValue('weight'),
];
$processor_id = $this->entity
->addProcessor($processor);
$this->entity
->save();
if (!empty($processor_id)) {
$this
->messenger()
->addMessage($this
->t('The Image Optimize processor was successfully applied.'));
}
}
}