You are here

public static function MatomoData::getUrl in Matomo Reports 8

Return Matomo server url.

Return value

string Stored value of Matomo server URL.

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

File

src/MatomoData.php, line 80

Class

MatomoData
Utility class for data retrieved by reports.

Namespace

Drupal\matomo_reports

Code

public static function getUrl() {

  // Matomo Reports settings takes precedence over Matomo settings.
  $url = \Drupal::config('matomo_reports.matomoreportssettings')
    ->get('matomo_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('Matomo server url is missing or wrong. Please ask your administrator to check Matomo Reports configuration.'));
  }
  return $url;
}