You are here

public static function PiwikData::getToken in Piwik Reports 8

Return piwik token auth from global or user.

Return value

string Piwik token auth.

2 calls to PiwikData::getToken()
PiwikReportsBlock::build in src/Plugin/Block/PiwikReportsBlock.php
Builds and returns the renderable array for this block plugin.
PiwikReportsController::reports in src/Controller/PiwikReportsController.php
Reports.

File

src/PiwikData.php, line 21
Contains \Drupal\piwik_reports\PiwikData.

Class

PiwikData

Namespace

Drupal\piwik_reports

Code

public static function getToken() {
  $config = \Drupal::config('piwik_reports.piwikreportssettings');
  $current_user = \Drupal::currentUser();
  $user_data = \Drupal::service('user.data')
    ->get('piwik_reports', $current_user
    ->id());
  $user_token = $current_user
    ->id() && isset($user_data['piwik_reports_token_auth']) ? $user_data['piwik_reports_token_auth'] : '';
  $token_auth = $config
    ->get('piwik_reports_token_auth') ? $config
    ->get('piwik_reports_token_auth') : $user_token;
  return Html::escape($token_auth);
}