JsonapiResourceConfigDeleteForm.php in JSON:API Extras 8.2
File
src/Form/JsonapiResourceConfigDeleteForm.php
View source
<?php
namespace Drupal\jsonapi_extras\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class JsonapiResourceConfigDeleteForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to revert %id to default?', [
'%id' => $this->entity
->id(),
]);
}
public function getCancelUrl() {
return new Url('entity.jsonapi_resource_config.collection');
}
public function getConfirmText() {
return $this
->t('Revert');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
drupal_set_message($this
->t('Resource %id has been reverted to default.', [
'%id' => $this->entity
->id(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}