You are here

public function PiwikAnalyticsService::getOutput in Analytics 7

Returns the output of the analytics service.

Parameters

array $context:

Return value

array A structured, renderable array.

Overrides AnalyticsServiceInterface::getOutput

File

analytics_piwik/src/PiwikAnalyticsService.php, line 39

Class

PiwikAnalyticsService

Code

public function getOutput(array $context) {
  $actions = array();
  $actions[] = array(
    'setSiteId',
    (int) $this
      ->getConfiguration()['id'],
  );
  $actions[] = "_paq.push(['setTrackerUrl', u+'piwik.php']);";
  $actions[] = array(
    'trackPageView',
  );
  $actions[] = array(
    'enableLinkTracking',
  );
  $actions = array_merge($actions, module_invoke_all('analytics_piwik_actions', $this, $context));
  drupal_alter('analytics_piwik_actions', $actions, $this, $context);
  $code = theme('analytics_piwik_js', array(
    'actions' => $actions,
    'service' => $this,
    'url' => $this->{$this}
      ->getConfiguration()['url'],
  ));
  $output = array();
  $output['#attached']['js'][] = array(
    'data' => $code,
    'type' => 'inline',
    //'weight' => 100000,
    'preprocess' => FALSE,
    'scope' => 'footer',
  );
  return $output;
}