"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/image/src/Form/ImageEffectDeleteForm.php" (26 Nov 2020, 1846 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ImageEffectDeleteForm.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\image\Form;
    4 
    5 use Drupal\Core\Form\ConfirmFormBase;
    6 use Drupal\Core\Form\FormStateInterface;
    7 use Drupal\image\ImageStyleInterface;
    8 
    9 /**
   10  * Form for deleting an image effect.
   11  *
   12  * @internal
   13  */
   14 class ImageEffectDeleteForm extends ConfirmFormBase {
   15 
   16   /**
   17    * The image style containing the image effect to be deleted.
   18    *
   19    * @var \Drupal\image\ImageStyleInterface
   20    */
   21   protected $imageStyle;
   22 
   23   /**
   24    * The image effect to be deleted.
   25    *
   26    * @var \Drupal\image\ImageEffectInterface
   27    */
   28   protected $imageEffect;
   29 
   30   /**
   31    * {@inheritdoc}
   32    */
   33   public function getQuestion() {
   34     return $this->t('Are you sure you want to delete the @effect effect from the %style style?', ['%style' => $this->imageStyle->label(), '@effect' => $this->imageEffect->label()]);
   35   }
   36 
   37   /**
   38    * {@inheritdoc}
   39    */
   40   public function getConfirmText() {
   41     return $this->t('Delete');
   42   }
   43 
   44   /**
   45    * {@inheritdoc}
   46    */
   47   public function getCancelUrl() {
   48     return $this->imageStyle->toUrl('edit-form');
   49   }
   50 
   51   /**
   52    * {@inheritdoc}
   53    */
   54   public function getFormId() {
   55     return 'image_effect_delete_form';
   56   }
   57 
   58   /**
   59    * {@inheritdoc}
   60    */
   61   public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
   62     $this->imageStyle = $image_style;
   63     $this->imageEffect = $this->imageStyle->getEffect($image_effect);
   64 
   65     return parent::buildForm($form, $form_state);
   66   }
   67 
   68   /**
   69    * {@inheritdoc}
   70    */
   71   public function submitForm(array &$form, FormStateInterface $form_state) {
   72     $this->imageStyle->deleteImageEffect($this->imageEffect);
   73     $this->messenger()->addStatus($this->t('The image effect %name has been deleted.', ['%name' => $this->imageEffect->label()]));
   74     $form_state->setRedirectUrl($this->imageStyle->toUrl('edit-form'));
   75   }
   76 
   77 }