You are here

function matomo_reports_user_profile_form_submit in Matomo Reports 8

Submit callback for user profile form to save the Matomo Reports setting.

1 string reference to 'matomo_reports_user_profile_form_submit'
matomo_reports_form_user_form_alter in ./matomo_reports.module
Implements hook_form_FORM_ID_alter().

File

./matomo_reports.module, line 67
Contains matomo_reports.module.

Code

function matomo_reports_user_profile_form_submit($form, FormStateInterface $form_state) {
  $account = $form_state
    ->getFormObject()
    ->getEntity();
  if ($account
    ->id() && $form_state
    ->hasValue('matomo_reports_token_auth')) {
    \Drupal::service('user.data')
      ->set('matomo_reports', $account
      ->id(), 'matomo_reports_token_auth', $form_state
      ->getValue('matomo_reports_token_auth'));
  }
}