You are here

private function AdminSettingsForm::preValidateData in Acquia Lift Connector 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/AdminSettingsForm.php \Drupal\acquia_lift\Form\AdminSettingsForm::preValidateData()

Pre-validate data.

1 call to AdminSettingsForm::preValidateData()
AdminSettingsForm::buildForm in src/Form/AdminSettingsForm.php
Form constructor.

File

src/Form/AdminSettingsForm.php, line 104

Class

AdminSettingsForm
Defines a form that configures settings.

Namespace

Drupal\acquia_lift\Form

Code

private function preValidateData() {
  $credential_settings = $this
    ->config('acquia_lift.settings')
    ->get('credential');

  // Validate the essential fields.
  if (SettingsHelper::isInvalidCredentialAccountId($credential_settings['account_id']) || SettingsHelper::isInvalidCredentialSiteId($credential_settings['site_id']) || SettingsHelper::isInvalidCredentialAssetsUrl($credential_settings['assets_url'])) {
    $this
      ->setFormMessage($this
      ->t('The Acquia Lift module requires a valid Account ID, Site ID, and Assets URL to complete activation.'), 'warning');
  }

  // Validate URLs and check connections.
  if (isset($credential_settings['decision_api_url']) && SettingsHelper::isInvalidCredentialDecisionApiUrl($credential_settings['decision_api_url']) || isset($credential_settings['oauth_url']) && SettingsHelper::isInvalidCredentialOauthUrl($credential_settings['oauth_url'])) {
    $this
      ->setFormMessage($this
      ->t('Acquia Lift module requires valid Decision API URL and Authentication URL to be activate.'), 'warning');
  }
}