You are here

class AutoLink in Googalytics - Google Analytics 8

Class AutoLink.

Hierarchy

Expanded class hierarchy of AutoLink

2 files declare their use of AutoLink
AutoLinkTest.php in tests/src/Unit/AnalyticsCommand/Linker/AutoLinkTest.php
DefaultCommandSubscriber.php in src/EventSubscriber/DefaultCommandSubscriber.php

File

src/AnalyticsCommand/Linker/AutoLink.php, line 10

Namespace

Drupal\ga\AnalyticsCommand\Linker
View source
class AutoLink extends Generic {

  /**
   * A list of domains.
   *
   * @var array
   */
  protected $domains;

  /**
   * Add linker parameter to anchor rather than query.
   *
   * @var bool|null
   */
  protected $useAnchor;

  /**
   * Add linker parameters to form submissions.
   *
   * @var bool|null
   */
  protected $decorateForms;

  /**
   * Create constructor.
   *
   * @param array $domains
   *   A list of domains.
   * @param bool|null $useAnchor
   *   Add linker parameter to anchor rather than query (optional).
   * @param bool|null $decorateForms
   *   Add linker parameters to form submissions (optional).
   * @param string $tracker_name
   *   The tracker name (optional).
   * @param int $priority
   *   The command priority.
   */
  public function __construct(array $domains, $useAnchor = NULL, $decorateForms = NULL, $tracker_name = NULL, $priority = parent::DEFAULT_PRIORITY) {
    parent::__construct('linker:autoLink', [], $tracker_name, $priority);
    $this->domains = $domains;
    $this->useAnchor = $useAnchor;
    $this->decorateForms = $decorateForms;
  }

  /**
   * {@inheritdoc}
   */
  public function getSettingCommands() {
    $command = [
      ($this->trackerName ? $this->trackerName . '.' : '') . $this->command,
      $this->domains,
    ];
    if (!is_null($this->useAnchor)) {
      $command[] = $this->useAnchor;
    }
    elseif (!is_null($this->decorateForms)) {
      $command[] = FALSE;
    }
    if (!is_null($this->decorateForms)) {
      $command[] = $this->decorateForms;
    }
    return [
      $command,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AutoLink::$decorateForms protected property Add linker parameters to form submissions.
AutoLink::$domains protected property A list of domains.
AutoLink::$useAnchor protected property Add linker parameter to anchor rather than query.
AutoLink::getSettingCommands public function An array of commands to be sent to Google Analytics. Overrides Generic::getSettingCommands
AutoLink::__construct public function Create constructor. Overrides Generic::__construct
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::DEFAULT_PRIORITY constant 4
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.