public function GoogleAnalyticsCounterAuthForm::submitForm in Google Analytics Counter 8.3
Form submission 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 ConfigFormBase::submitForm
File
- src/
Form/ GoogleAnalyticsCounterAuthForm.php, line 222
Class
- GoogleAnalyticsCounterAuthForm
- Class GoogleAnalyticsCounterAuthForm.
Namespace
Drupal\google_analytics_counter\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('google_analytics_counter.settings');
switch ($form_state
->getValue('op')) {
case (string) $this
->t('Authenticate'):
$this->authManager
->beginGacAuthentication();
break;
case (string) $this
->t('Revoke authentication'):
$form_state
->setRedirectUrl(Url::fromRoute('google_analytics_counter.admin_auth_revoke'));
break;
default:
$options = $this->authManager
->getWebPropertiesOptions();
$profile_id = $form_state
->getValue('profile_id');
$profile_name = GoogleAnalyticsCounterHelper::searchArrayValueByKey($options, (int) $profile_id);
$config
->set('general_settings.client_id', $form_state
->getValue('client_id'))
->set('general_settings.client_secret', $form_state
->getValue('client_secret'))
->set('general_settings.redirect_uri', $form_state
->getValue('redirect_uri'))
->set('general_settings.project_name', $form_state
->getValue('project_name'))
->set('general_settings.profile_id', $form_state
->getValue('profile_id'))
->set('general_settings.profile_name', $profile_name)
->save();
parent::submitForm($form, $form_state);
break;
}
}