You are here

class AmpQueryParameters in Accelerated Mobile Pages (AMP) 8.3

Same name and namespace in other branches
  1. 8 src/Utility/AmpQueryParameters.php \Drupal\amp\Utility\AmpQueryParameters
  2. 8.2 src/Utility/AmpQueryParameters.php \Drupal\amp\Utility\AmpQueryParameters

Class AmpQueryParameters

Adds amp query parameters to a URL.

@package Drupal\amp\Utility

Hierarchy

Expanded class hierarchy of AmpQueryParameters

1 string reference to 'AmpQueryParameters'
amp.services.yml in ./amp.services.yml
amp.services.yml
1 service uses AmpQueryParameters
amp.query_parameters in ./amp.services.yml
Drupal\amp\Utility\AmpQueryParameters

File

src/Utility/AmpQueryParameters.php, line 14

Namespace

Drupal\amp\Utility
View source
class AmpQueryParameters extends ServiceProviderBase {

  /**
   * Add amp query parameter to a URL.
   *
   * @param string $url
   *   The original URL value.
   * @param boolean $development
   *   Option to append development to the end of the URL.
   *
   * @return string
   *   A url containing the additional amp query parameter(s).
   */
  public function add($url, $development = FALSE) {

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

    // Append optional development query string parameter.
    if ($development) {
      $amp_url = $amp_url . "&debug#development=1";
    }
    return $amp_url;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AmpQueryParameters::add public function Add amp query parameter to a URL.
ServiceProviderBase::alter public function Modifies existing service definitions. Overrides ServiceModifierInterface::alter 5
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1