You are here

public function ApigeeAuthKeyInput::validateConfigurationForm in Apigee Edge 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides KeyInputBase::validateConfigurationForm

File

src/Plugin/KeyInput/ApigeeAuthKeyInput.php, line 254

Class

ApigeeAuthKeyInput
Apigee Edge authentication credentials input text fields.

Namespace

Drupal\apigee_edge\Plugin\KeyInput

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $input_values = $form_state
    ->getUserInput()['key_input_settings'];
  if ($input_values['instance_type'] == EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID && empty($input_values['gcp_hosted'])) {
    $account_key = $input_values['account_json_key'] ?? '';
    $json = json_decode($account_key, TRUE);
    if (empty($json['private_key']) || empty($json['client_email'])) {
      $form_state
        ->setErrorByName('key_input_settings][account_json_key', $this
        ->t('GCP service account key JSON file is invalid.'));
    }
  }
}