You are here

public function DemoDeleteConfirm::submitForm in Demonstration site (Sandbox / Snapshot) 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/DemoDeleteConfirm.php, line 49

Class

DemoDeleteConfirm
This class return the demo_delete_confirm, a form where you will be asked to be sure to delete your config file.

Namespace

Drupal\demo\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $files = demo_get_fileconfig($form_state
    ->getValue([
    'filename',
  ]));
  unlink($files['sqlfile']);
  unlink($files['infofile']);
  \Drupal::messenger()
    ->addMessage(t('Snapshot %title has been deleted.', [
    '%title' => $form_state
      ->getValue([
      'filename',
    ]),
  ]));
  $form_state
    ->setRedirect('demo.manage_form');
}