public function AcquiadamConfig::validateForm in Media: Acquia DAM 8
Form validation 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 FormBase::validateForm
File
- src/Form/ AcquiadamConfig.php, line 374 
Class
- AcquiadamConfig
- Class AcquiadamConfig.
Namespace
Drupal\media_acquiadam\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
  // We set the client data array with the values from form_state.
  $username = $form_state
    ->getValue('username');
  $password = $this
    ->getFieldValue($form_state, 'password');
  $form_state
    ->setValue('password', $password);
  $client_id = $form_state
    ->getValue('client_id');
  $client_secret = $this
    ->getFieldValue($form_state, 'secret');
  $form_state
    ->setValue('secret', $client_secret);
  try {
    $acquiadam_client = $this->acquiaDamClientFactory
      ->getWithCredentials($username, $password, $client_id, $client_secret);
    $acquiadam_client
      ->getAccountSubscriptionDetails();
  } catch (InvalidCredentialsException $e) {
    $form_state
      ->setErrorByName('authentication', $e
      ->getMessage());
  }
}