FlushAllForm.php in Textimage 8.3
File
src/Form/FlushAllForm.php
View source
<?php
namespace Drupal\textimage\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\textimage\TextimageFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FlushAllForm extends ConfirmFormBase {
protected $textimageFactory;
public function __construct(TextimageFactory $textimage_factory) {
$this->textimageFactory = $textimage_factory;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('textimage.factory'));
}
public function getFormId() {
return 'textimage_flush_all_form';
}
public function getQuestion() {
return $this
->t('Cleanup Textimage?');
}
public function getDescription() {
return $this
->t('This will remove all image files generated via Textimage, flush all the image styles, and clear the Textimage cache.');
}
public function getConfirmText() {
return $this
->t('Proceed');
}
public function getCancelUrl() {
return new Url('textimage.settings');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->textimageFactory
->flushAll();
$form_state
->setRedirect('textimage.settings');
}
}
Classes
Name |
Description |
FlushAllForm |
Creates a form to confirm flushing of all Textimage images. |