diff --git a/core/modules/image/image.routing.yml b/core/modules/image/image.routing.yml index 8bb3da5..97ebd95 100644 --- a/core/modules/image/image.routing.yml +++ b/core/modules/image/image.routing.yml @@ -23,7 +23,8 @@ image.style_delete: image.style_flush: path: 'admin/config/media/image-styles/manage/{image_style}/flush' defaults: - _form: '\Drupal\image\Form\ImageStyleFlushForm' + _entity_form: 'image_style.flush' + _title: 'Flush' requirements: _permission: 'administer image styles' diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index aabef1e..ca4bece 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -29,7 +29,8 @@ * "form" = { * "add" = "Drupal\image\Form\ImageStyleAddForm", * "edit" = "Drupal\image\Form\ImageStyleEditForm", - * "delete" = "Drupal\image\Form\ImageStyleDeleteForm" + * "delete" = "Drupal\image\Form\ImageStyleDeleteForm", + * "flush" = "Drupal\image\Form\ImageStyleFlushForm" * }, * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController", * "list" = "Drupal\image\ImageStyleListController", diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php index 4e3a9ff..42065d0 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php @@ -7,40 +7,25 @@ namespace Drupal\image\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\image\ImageStyleInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; /** - * Base form controller for image style flush. + * Form controller for image style flush. */ -class ImageStyleFlushForm extends ConfirmFormBase { - - /** - * The image style object. - * - * @var \Drupal\image\Entity\ImageStyle - */ - protected $image_style; - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'image_style_flush'; - } +class ImageStyleFlushForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to flush image derivatives for %name image style?', array('%name' => $this->image_style->label())); + return $this->t('Are you sure you want to flush image derivatives for %name image style?', array('%name' => $this->entity->label())); } /** * {@inheritdoc} */ public function getDescription() { - return $this->t('This action cannot be undone. Image derivatives will be magically recreated as they are requested.'); + return parent::getDescription() . ' ' . $this->t('Image derivatives are the result of processing original images through the image styling. These derived images are stored in the file system to speed up further visits. Flushing them now will lead Drupal to recreate the derivatives as they are requested next time.'); } /** @@ -57,23 +42,17 @@ public function getCancelRoute() { return array( 'route_name' => 'image.style_list', 'route_parameters' => array( - 'image_style' => $this->image_style->id(), + 'image_style' => $this->entity->id(), ), ); } - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL) { - $this->image_style = $image_style; - - return parent::buildForm($form, $form_state); - } - /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->image_style->flush(); - drupal_set_message($this->t('The image style %name has been flushed.', array('%name' => $this->image_style->label()))); + public function submit(array $form, array &$form_state) { + $this->entity->flush(); + drupal_set_message($this->t('The image style %name has been flushed.', array('%name' => $this->entity->label()))); $form_state['redirect'] = 'admin/config/media/image-styles'; }