DemoResetConfirm.php in Demonstration site (Sandbox / Snapshot) 8
File
src/Form/DemoResetConfirm.php
View source
<?php
namespace Drupal\demo\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Url;
class DemoResetConfirm extends ConfirmFormBase {
public function getFormId() {
return 'demo_reset_confirm';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['dump'] = demo_get_dumps();
\Drupal::messenger()
->addMessage(t('This action cannot be undone.'), 'warning');
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Reset now'),
];
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
}
public function submitForm(array &$form, FormStateInterface $form_state) {
_demo_reset($form_state
->getValue([
'filename',
]));
}
public function getCancelUrl() {
return new Url('demo.manage_form');
}
public function getQuestion() {
return t('Do you want to reset the site?');
}
public function getConfirmText() {
return t('Delete');
}
}
Classes
Name |
Description |
DemoResetConfirm |
Returns demo_reset_confirm from to make sure that you really want to reset the configuration. |