public function SettingsForm::requestToken in Siteimprove 8
Implements callback for Ajax event on token request.
Parameters
array $form: From render array.
\Drupal\Core\Form\FormStateInterface $form_state: Current state of form.
Return value
array Token field with value filled.
File
- src/
Form/ SettingsForm.php, line 343
Class
- SettingsForm
- Siteimprove settings.
Namespace
Drupal\siteimprove\FormCode
public function requestToken(array &$form, FormStateInterface &$form_state) {
// Request new token.
if ($token = $this->siteimprove
->requestToken()) {
$form['container']['token']['#value'] = $token;
}
else {
$this->messenger
->addError($this
->t('There was an error requesting a new token. Please try again in a few minutes.'));
}
$form_state
->setRebuild(TRUE);
return $form['container']['token'];
}