You are here

ImageAPIOptimizePipelineFlushForm.php in Image Optimize (or ImageAPI Optimize) 8.2

File

src/Form/ImageAPIOptimizePipelineFlushForm.php
View source
<?php

namespace Drupal\imageapi_optimize\Form;

use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for image optimize pipeline flush.
 */
class ImageAPIOptimizePipelineFlushForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  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(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this
      ->t('This operation does not change the original images but the copies created for this pipeline will be recreated.');
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this
      ->t('Flush');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return $this->entity
      ->toUrl('collection');
  }

  /**
   * {@inheritdoc}
   */
  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());
  }

}

Classes

Namesort descending Description
ImageAPIOptimizePipelineFlushForm Form controller for image optimize pipeline flush.