class ImageEffectDeleteForm

Form for deleting an image effect.

Hierarchy

Expanded class hierarchy of ImageEffectDeleteForm

1 string reference to 'ImageEffectDeleteForm'
image.routing.yml in drupal/core/modules/image/image.routing.yml
drupal/core/modules/image/image.routing.yml

File

drupal/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php, line 16
Contains \Drupal\image\Form\ImageEffectDeleteForm.

Namespace

Drupal\image\Form
View source
class ImageEffectDeleteForm extends ConfirmFormBase {

  /**
   * The image style containing the image effect to be deleted.
   *
   * @var \Drupal\image\Plugin\Core\Entity\ImageStyle
   */
  protected $imageStyle;

  /**
   * The image effect to be deleted.
   *
   * @var array;
   */
  protected $imageEffect;

  /**
   * {@inheritdoc}
   */
  protected function getQuestion() {
    return t('Are you sure you want to delete the @effect effect from the %style style?', array(
      '%style' => $this->imageStyle
        ->label(),
      '@effect' => $this->imageEffect['label'],
    ));
  }

  /**
   * {@inheritdoc}
   */
  protected function getConfirmText() {
    return t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  protected function getCancelPath() {
    return 'admin/config/media/image-styles/manage/' . $this->imageStyle
      ->id();
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'image_effect_delete_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state, $image_style = NULL, $image_effect = NULL) {
    $this->imageStyle = $image_style;
    $this->imageEffect = image_effect_load($image_effect, $this->imageStyle
      ->id());
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    image_effect_delete($this->imageStyle, $this->imageEffect);
    drupal_set_message(t('The image effect %name has been deleted.', array(
      '%name' => $this->imageEffect['label'],
    )));
    $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $this->imageStyle
      ->id();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getDescription protected function Returns additional text to display as a description. 10
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1
ImageEffectDeleteForm::$imageEffect protected property The image effect to be deleted.
ImageEffectDeleteForm::$imageStyle protected property The image style containing the image effect to be deleted.
ImageEffectDeleteForm::buildForm public function Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides ConfirmFormBase::buildForm
ImageEffectDeleteForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
ImageEffectDeleteForm::getConfirmText protected function Returns a caption for the button that confirms the action. Overrides ConfirmFormBase::getConfirmText
ImageEffectDeleteForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
ImageEffectDeleteForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
ImageEffectDeleteForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm