public static function MatomoData::getToken in Matomo Reports 8
Return matomo token auth from global or user.
Return value
string Matomo token auth.
2 calls to MatomoData::getToken()
- MatomoReportsBlock::build in src/
Plugin/ Block/ MatomoReportsBlock.php - Builds and returns the renderable array for this block plugin.
- MatomoReportsController::reports in src/
Controller/ MatomoReportsController.php - Reports.
File
- src/
MatomoData.php, line 19
Class
- MatomoData
- Utility class for data retrieved by reports.
Namespace
Drupal\matomo_reportsCode
public static function getToken() {
$config = \Drupal::config('matomo_reports.matomoreportssettings');
$current_user = \Drupal::currentUser();
$user_data = \Drupal::service('user.data')
->get('matomo_reports', $current_user
->id());
$user_token = $current_user
->id() && isset($user_data['matomo_reports_token_auth']) ? $user_data['matomo_reports_token_auth'] : '';
$token_auth = $config
->get('matomo_reports_token_auth') ? $config
->get('matomo_reports_token_auth') : $user_token;
return Html::escape($token_auth);
}