filefield_sources_jsonapi-8.x-1.0-beta9/src/Form/FileFieldSourcesJSONAPIDeleteForm.php
src/Form/FileFieldSourcesJSONAPIDeleteForm.php
<?php
namespace Drupal\filefield_sources_jsonapi\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Builds the form to delete Classy paragraphs style entities.
*/
class FileFieldSourcesJSONAPIDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.filefield_sources_jsonapi.collection');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
$this->messenger()->addMessage(
$this->t('Deleted the %label JSON API settings.', [
'@type' => $this->entity->bundle(),
'%label' => $this->entity->label(),
])
);
$form_state->setRedirectUrl($this->getCancelUrl());
}
}
