You are here

public function BrightcoveClientEntityUIController::operationFormValidate in Brightcove Video Connect 7.6

Same name and namespace in other branches
  1. 7.7 brightcove.client.inc \BrightcoveClientEntityUIController::operationFormValidate()

@inheritdoc

Overrides EntityDefaultUIController::operationFormValidate

File

./brightcove.client.inc, line 59
Client related code.

Class

BrightcoveClientEntityUIController
Admin UI controller for 'brightcove_client' entity type.

Code

public function operationFormValidate($form, &$form_state) {
  parent::operationFormValidate($form, $form_state);
  if ($form_state['op'] === 'import') {
    $import = $form_state['values']['import'];
    $json = json_decode($import, TRUE);
    if ($json) {
      brightcove_try(function () use ($json) {
        $client_id = isset($json['client_id']) ? $json['client_id'] : NULL;
        $client_secret = isset($json['client_secret']) ? $json['client_secret'] : NULL;
        \Brightcove\API\Client::authorize($client_id, $client_secret);
      }, function () {
        form_set_error('import', t("Invalid credentials."));
      });
    }
  }
}