class ImageEffectDeleteForm
Same name and namespace in other branches
- 11.x core/modules/image/src/Form/ImageEffectDeleteForm.php \Drupal\image\Form\ImageEffectDeleteForm
Form for deleting an image effect.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase extends \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Form\ConfirmFormBase extends \Drupal\Core\Form\ConfirmFormInterface implements \Drupal\Core\Form\FormBase
- class \Drupal\image\Form\ImageEffectDeleteForm implements \Drupal\Core\Form\ConfirmFormBase
- class \Drupal\Core\Form\ConfirmFormBase extends \Drupal\Core\Form\ConfirmFormInterface implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of ImageEffectDeleteForm
1 string reference to 'ImageEffectDeleteForm'
- image.routing.yml in core/
modules/ image/ image.routing.yml - core/modules/image/image.routing.yml
File
-
core/
modules/ image/ src/ Form/ ImageEffectDeleteForm.php, line 14
Namespace
Drupal\image\FormView source
class ImageEffectDeleteForm extends ConfirmFormBase {
/**
* The image style containing the image effect to be deleted.
*
* @var \Drupal\image\ImageStyleInterface
*/
protected $imageStyle;
/**
* The image effect to be deleted.
*
* @var \Drupal\image\ImageEffectInterface
*/
protected $imageEffect;
/**
* {@inheritdoc}
*/
public function getQuestion() {
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(),
]);
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return $this->imageStyle
->toUrl('edit-form');
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'image_effect_delete_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
$this->imageStyle = $image_style;
$this->imageEffect = $this->imageStyle
->getEffect($image_effect);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->imageStyle
->deleteImageEffect($this->imageEffect);
$this->messenger()
->addStatus($this->t('The image effect %name has been deleted.', [
'%name' => $this->imageEffect
->label(),
]));
$form_state->setRedirectUrl($this->imageStyle
->toUrl('edit-form'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.