You are here

public function AmpQueryParameters::add in Accelerated Mobile Pages (AMP) 8

Same name and namespace in other branches
  1. 8.3 src/Utility/AmpQueryParameters.php \Drupal\amp\Utility\AmpQueryParameters::add()
  2. 8.2 src/Utility/AmpQueryParameters.php \Drupal\amp\Utility\AmpQueryParameters::add()

Add amp query parameter to a URL.

Parameters

string $url: The original URL value.

boolean $warnfix: Option to append warnfix to the end of the URL.

Return value

string A url containing the additional amp query parameter(s).

File

src/Utility/AmpQueryParameters.php, line 25

Class

AmpQueryParameters
Class AmpQueryParameters

Namespace

Drupal\amp\Utility

Code

public function add($url, $warnfix = FALSE) {

  // Append amp query string parameter
  if (strpos($url, '?') === FALSE) {
    $amp_url = $url . "?amp";
  }
  else {
    $amp_url = $url . "&amp";
  }

  // Append optional warnfix query string parameter.
  if ($warnfix) {
    $amp_url = $amp_url . "&warnfix";
  }
  return $amp_url;
}