You are here

public function Authorize::submitForm in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Form/Authorize.php \Drupal\drd_agent\Form\Authorize::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.

Overrides FormInterface::submitForm

File

src/Form/Authorize.php, line 122

Class

Authorize
Authorize a new dashboard for this drd-agent.

Namespace

Drupal\drd_agent\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if (empty($_SESSION['drd_agent_authorization_values'])) {
    $_SESSION['drd_agent_authorization_values'] = $form_state
      ->getValue('token');
  }
  else {
    if ($form_state
      ->getValue('op') === $form['submit']['#value']) {
      $values = $this->setupService
        ->execute();
      $form_state
        ->setResponse(TrustedRedirectResponse::create($values['redirect']));
    }
    unset($_SESSION['drd_agent_authorization_values']);
  }
}