You are here

public static function AnalyticsJsMarkup::create in Analytics 8

inheritdoc}

Overrides MarkupTrait::create

1 call to AnalyticsJsMarkup::create()
GoogleTagManager::getOutput in src/Plugin/AnalyticsService/GoogleTagManager.php
Returns the output of the analytics service.

File

src/Render/AnalyticsJsMarkup.php, line 26

Class

AnalyticsJsMarkup
Defines an object that passes safe strings through the render system.

Namespace

Drupal\analytics\Render

Code

public static function create($string) {
  if ($string instanceof self) {
    return $string;
  }
  $string = (string) $string;
  if ($string === '') {
    return '';
  }
  if (static::isDntEnforced()) {
    $string = "if (!navigator.doNotTrack && !window.doNotTrack && !navigator.msDoNotTrack) {\n" . $string . "\n}";
  }
  $safe_string = new static();
  $safe_string->string = $string;
  return $safe_string;
}