You are here

public function EntityDeleteForm::submitForm in Entity Delete 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/EntityDeleteForm.php, line 159

Class

EntityDeleteForm
Class EntityDeleteForm.

Namespace

Drupal\entity_delete\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Get $form_state values.
  $values = $form_state
    ->getValues();

  // Entity type.
  $entity_type = $values['show']['entity_type'];

  // Get bundle.
  $bundle = $values['show']['type'];
  $url = Url::fromRoute('entity_delete.entity_delete_confirmation', [
    'entity_type' => $entity_type,
    'bundle' => $bundle,
  ]);
  $token = $this->csrfToken
    ->get($url
    ->getInternalPath());
  $url
    ->setOptions([
    'query' => [
      'token' => $token,
    ],
  ]);
  $form_state
    ->setRedirectUrl($url);
}