You are here

public static function PiwikData::getUrl in Piwik Reports 8

Return Piwik server url.

Return value

string Stored value of Piwik server URL.

4 calls to PiwikData::getUrl()
PiwikData::getSites in src/PiwikData.php
Return a list of sites where statistics are accessible on piwik server.
PiwikReportsBlock::build in src/Plugin/Block/PiwikReportsBlock.php
Builds and returns the renderable array for this block plugin.
PiwikReportsController::piwik_reports_get_goals in src/Controller/PiwikReportsController.php
Return a list of goals active on selected site.
PiwikReportsController::reports in src/Controller/PiwikReportsController.php
Reports.

File

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

Class

PiwikData

Namespace

Drupal\piwik_reports

Code

public static function getUrl() {

  // Piwik Reports settings takes precedence over Matomo settings.
  $url = \Drupal::config('piwik_reports.piwikreportssettings')
    ->get('piwik_server_url');
  if ($url == '') {
    if (\Drupal::moduleHandler()
      ->moduleExists('matomo')) {

      //get https url if available first
      $url = \Drupal::config('matomo.settings')
        ->get('url_http');
      $url = \Drupal::config('matomo.settings')
        ->get('url_https') ? \Drupal::config('matomo.settings')
        ->get('url_https') : $url;
    }
  }
  if ($url == '') {
    \Drupal::messenger()
      ->addWarning(t('Piwik server url is missing or wrong. Please ask your administrator to check Piwik Reports configuration.'));
  }
  return $url;
}