You are here

public function YandexServicesAuthForm::submitForm in Yandex Services Authorization API 8

Implements \Drupal\Core\Form\FormInterface::submitForm().

Overrides FormInterface::submitForm

File

lib/Drupal/yandex_services_auth/Form/YandexServicesAuthForm.php, line 75
Contains \Drupal\yandex_metrics\Form\YandexMetricsCounterSettingsForm.

Class

YandexServicesAuthForm
Provides form for Yandex Services Authorization.

Namespace

Drupal\yandex_services_auth\Form

Code

public function submitForm(array &$form, array &$form_state) {
  $client_id = $form_state['values']['yandex_services_auth_client_id'];
  \Drupal::state()
    ->set('yandex_services_auth_client_id', $form_state['values']['yandex_services_auth_client_id']);
  \Drupal::state()
    ->set('yandex_services_auth_client_secret', $form_state['values']['yandex_services_auth_client_secret']);
  $request_url = 'https://oauth.yandex.ru/authorize';
  $params = array(
    'response_type' => 'code',
    'client_id' => $client_id,
  );
  $form_state['redirect'] = url($request_url, array(
    'query' => $params,
    'external' => TRUE,
  ));
}