You are here

public function TagView::getShortTagQueryString in Doubleclick for Publishers (DFP) 8

Gets the short tag query string.

Return value

string The short tag query string.

See also

https://support.google.com/dfp_sb/answer/2623168

File

src/View/TagView.php, line 189
Contains \Drupal\dfp\View\TagView.

Class

TagView
A value object to combine a DFP tag with global settings for display.

Namespace

Drupal\dfp\View

Code

public function getShortTagQueryString() {
  if (is_null($this->shortTagQueryString)) {

    // Build a key|values array and allow third party modules to modify it.
    $key_values = [
      'iu' => $this
        ->getAdUnit(),
      'sz' => str_replace(',', '|', $this
        ->getRawSize()),
      'c' => mt_rand(10000, 99999),
    ];
    $targets = [];
    foreach ($this
      ->getRawTargeting() as $data) {
      $targets[] = $data['target'] . '=' . $data['value'];
    }
    if (!empty($targets)) {
      $key_values['t'] = implode('&', $targets);
    }
    $this->moduleHandler
      ->alter('dfp_short_tag_keyvals', $key_values);
    $this->shortTagQueryString = UrlHelper::buildQuery($key_values);
  }
  return $this->shortTagQueryString;
}