You are here

class AuthcacheP13nDefaultRequestUrlGenerator in Authenticated User Page Caching (Authcache) 7.2

Interface for request url generators.

Hierarchy

Expanded class hierarchy of AuthcacheP13nDefaultRequestUrlGenerator

2 string references to 'AuthcacheP13nDefaultRequestUrlGenerator'
AuthcacheP13nTestRequestBuilder::testRequestResourcesNullFragments in modules/authcache_p13n/tests/authcache_p13n.request-builder.test
Cover authcache_p13n_request_resources().
authcache_p13n_authcache_p13n_base_request in modules/authcache_p13n/authcache_p13n.module
Implements hook_authcache_p13n_base_request().

File

modules/authcache_p13n/includes/AuthcacheP13nDefaultRequestUrlGenerator.inc, line 11
Defines request URL generator.

View source
class AuthcacheP13nDefaultRequestUrlGenerator implements AuthcacheP13nRequestUrlGeneratorInterface {

  /**
   * Personalization fragment frontcontroller relative to DRUPAL_ROOT.
   */
  protected $frontControllerURL;

  /**
   * @var AuthcacheP13nCacheGranularity
   */
  protected $cacheGranularity;

  /**
   * Construct new request URL generator.
   *
   * @param String $front_controller
   *   Path to the personalization fragment frontcontroller relative to
   *   DRUPAL_ROOT.
   * @param int $cache_granularity
   *   Cache granularity.
   */
  public function __construct($front_controller, AuthcacheP13nCacheGranularity $cache_granularity) {

    // If the frontcontroller is given as a relative path, prepend it with the
    // base path.
    $parts = parse_url($front_controller);
    if (empty($parts['host'])) {
      $this->frontControllerURL = base_path() . $front_controller;
    }
    else {
      $this->frontControllerURL = $front_controller;
    }
    $this->cacheGranularity = $cache_granularity;
  }

  /**
   * {@inheritdoc}
   */
  public function url($route_id, $arg) {
    $query = array(
      'a' => $arg,
      'r' => $route_id,
    );

    // Add path for per-page caching.
    if ($this->cacheGranularity
      ->is(AuthcacheP13nCacheGranularity::PER_PAGE)) {
      $query['o'] = $_GET;
    }
    else {
      $query['o'] = array(
        'q' => '',
      );
    }

    // Add language specific URL prefix if there is any.
    url('', array(
      'prefix' => &$prefix,
    ));
    $query['o']['q'] = $prefix . $query['o']['q'];
    return array(
      'path' => $this->frontControllerURL,
      'options' => array(
        'external' => TRUE,
        'query' => $query,
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthcacheP13nDefaultRequestUrlGenerator::$cacheGranularity protected property
AuthcacheP13nDefaultRequestUrlGenerator::$frontControllerURL protected property Personalization fragment frontcontroller relative to DRUPAL_ROOT.
AuthcacheP13nDefaultRequestUrlGenerator::url public function Generate an url for the given request and parameter. Overrides AuthcacheP13nRequestUrlGeneratorInterface::url
AuthcacheP13nDefaultRequestUrlGenerator::__construct public function Construct new request URL generator.