You are here

class Set in Googalytics - Google Analytics 8

Class Set.

Hierarchy

Expanded class hierarchy of Set

2 files declare their use of Set
DefaultCommandSubscriber.php in src/EventSubscriber/DefaultCommandSubscriber.php
SetTest.php in tests/src/Unit/AnalyticsCommand/SetTest.php

File

src/AnalyticsCommand/Set.php, line 8

Namespace

Drupal\ga\AnalyticsCommand
View source
class Set extends Generic {
  const DEFAULT_PRIORITY = 100;

  /**
   * The setting key.
   *
   * @var string
   */
  protected $settingKey;

  /**
   * The setting value.
   *
   * @var mixed
   */
  protected $settingValue;

  /**
   * Create constructor.
   *
   * @param string $setting_key
   *   The setting key.
   * @param mixed $value
   *   The setting value.
   * @param array $fields_object
   *   A set of additional options for the command.
   * @param string $tracker_name
   *   The tracker name.
   * @param int $priority
   *   The command priority.
   */
  public function __construct($setting_key, $value, array $fields_object = [], $tracker_name = NULL, $priority = self::DEFAULT_PRIORITY) {
    parent::__construct('set', $fields_object, $tracker_name, $priority);
    $this->settingKey = $setting_key;
    $this->settingValue = $value;
  }

  /**
   * Get the setting key.
   *
   * @return string
   *   The setting key.
   */
  public function getSettingKey() {
    return $this->settingKey;
  }

  /**
   * Get the setting value.
   *
   * @return mixed
   *   The setting value.
   */
  public function getSettingValue() {
    return $this->settingValue;
  }

  /**
   * {@inheritdoc}
   */
  public function getSettingCommands() {
    $command = [
      ($this->trackerName ? $this->trackerName . '.' : '') . $this->command,
      $this->settingKey,
      $this->settingValue,
    ];
    if (!empty($this->fieldsObject)) {
      $command[] = $this->fieldsObject;
    }
    return [
      $command,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalSettingCommandsTrait::$priority protected property Priority integer.
DrupalSettingCommandsTrait::getPriority public function An integer value for sorting by priority.
Generic::$command protected property The command name.
Generic::$fieldsObject protected property A map of values for the command's fieldsObject parameter.
Generic::$trackerName protected property The name of the tracker for this command.
Generic::getCommand public function Get the command name.
Generic::getFieldsObject public function Get the map of values for the command's fieldsObject parameter.
Generic::getTrackerName public function The tracker this command will be applied to, if specified.
Set::$settingKey protected property The setting key.
Set::$settingValue protected property The setting value.
Set::DEFAULT_PRIORITY constant Overrides Generic::DEFAULT_PRIORITY
Set::getSettingCommands public function An array of commands to be sent to Google Analytics. Overrides Generic::getSettingCommands
Set::getSettingKey public function Get the setting key.
Set::getSettingValue public function Get the setting value.
Set::__construct public function Create constructor. Overrides Generic::__construct 2