You are here

class GoogleAnalyticsJavaScriptSnippet in Google Analytics 8.2

Same name and namespace in other branches
  1. 8.3 src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php \Drupal\google_analytics\Component\Render\GoogleAnalyticsJavaScriptSnippet
  2. 4.x src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php \Drupal\google_analytics\Component\Render\GoogleAnalyticsJavaScriptSnippet

Formats a string for JavaScript display.

Hierarchy

Expanded class hierarchy of GoogleAnalyticsJavaScriptSnippet

1 file declares its use of GoogleAnalyticsJavaScriptSnippet
google_analytics.module in ./google_analytics.module
Drupal Module: Google Analytics.

File

src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php, line 10

Namespace

Drupal\google_analytics\Component\Render
View source
class GoogleAnalyticsJavaScriptSnippet implements MarkupInterface {

  /**
   * The string to escape.
   *
   * @var string
   */
  protected $string;

  /**
   * Constructs an HtmlEscapedText object.
   *
   * @param string $string
   *   The string to escape. This value will be cast to a string.
   */
  public function __construct($string) {
    $this->string = (string) $string;
  }

  /**
   * {@inheritdoc}
   */
  public function __toString() {
    return $this->string;
  }

  /**
   * {@inheritdoc}
   */
  public function jsonSerialize() {
    return $this
      ->__toString();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GoogleAnalyticsJavaScriptSnippet::$string protected property The string to escape.
GoogleAnalyticsJavaScriptSnippet::jsonSerialize public function
GoogleAnalyticsJavaScriptSnippet::__construct public function Constructs an HtmlEscapedText object.
GoogleAnalyticsJavaScriptSnippet::__toString public function Returns markup. Overrides MarkupInterface::__toString