ImageAPIOptimizePipelineFlushForm.php in Image Optimize (or ImageAPI Optimize) 4.x
File
src/Form/ImageAPIOptimizePipelineFlushForm.php
View source
<?php
namespace Drupal\imageapi_optimize\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
class ImageAPIOptimizePipelineFlushForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to apply the updated %name Image Optimize pipeline to all images?', [
'%name' => $this->entity
->label(),
]);
}
public function getDescription() {
return $this
->t('This operation does not change the original images but the copies created for this pipeline will be recreated.');
}
public function getConfirmText() {
return $this
->t('Flush');
}
public function getCancelUrl() {
return $this->entity
->toUrl('collection');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->flush();
$this
->messenger()
->addMessage($this
->t('The Image Optimize pipeline %name has been flushed.', [
'%name' => $this->entity
->label(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}