function RestExampleClientDelete::submitForm

Same name and namespace in other branches
  1. 3.x modules/rest_example/src/Form/RestExampleClientDelete.php \Drupal\rest_example\Form\RestExampleClientDelete::submitForm()

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.

Throws

\GuzzleHttp\Exception\GuzzleException

Overrides FormInterface::submitForm

File

modules/rest_example/src/Form/RestExampleClientDelete.php, line 96

Class

RestExampleClientDelete
Delete a new node on a remote Drupal site.

Namespace

Drupal\rest_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $node_id = $form_state->get('node_id');
  $node = [
    'nid' => $node_id,
  ];
  $this->restExampleClientCalls
    ->delete($node);
  $this->messenger()
    ->addStatus($this->t('Node was successfully deleted'));
  $form_state->setRedirect('rest_example.client_actions_index');
}