You are here

class MyCache in Visually Impaired Support (module) 8

Extending PageCache.

Hierarchy

  • class \Drupal\page_cache\StackMiddleware\PageCache implements \Symfony\Component\HttpKernel\HttpKernelInterface
    • class \Drupal\visually_impaired_module\StackMiddleware\MyCache

Expanded class hierarchy of MyCache

File

src/StackMiddleware/MyCache.php, line 11

Namespace

Drupal\visually_impaired_module\StackMiddleware
View source
class MyCache extends PageCache {

  /**
   * Gets the page cache ID for this request.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   A request object.
   *
   * @return string
   *   The cache ID for this request.
   */
  protected function getCacheId(Request $request) {
    $cookie = '';
    if (isset($_COOKIE['visually_impaired'])) {
      $cookie = $_COOKIE['visually_impaired'];
    }
    $cid_parts = [
      $cookie,
      $request
        ->getSchemeAndHttpHost() . $request
        ->getRequestUri(),
      $request
        ->getRequestFormat(),
    ];
    return implode(':', $cid_parts);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MyCache::getCacheId protected function Gets the page cache ID for this request. Overrides PageCache::getCacheId
PageCache::$cache protected property The cache bin.
PageCache::$cid protected property The cache ID for the (master) request.
PageCache::$httpKernel protected property The wrapped HTTP kernel.
PageCache::$requestPolicy protected property A policy rule determining the cacheability of a request.
PageCache::$responsePolicy protected property A policy rule determining the cacheability of the response.
PageCache::fetch protected function Fetches a response from the backend and stores it in the cache.
PageCache::get protected function Returns a response object from the page cache.
PageCache::handle public function Handles a Request to convert it to a Response.
PageCache::lookup protected function Retrieves a response from the cache or fetches it from the backend.
PageCache::pass protected function Sidesteps the page cache and directly forwards a request to the backend.
PageCache::set protected function Stores a response object in the page cache.
PageCache::storeResponse protected function Stores a response in the page cache.
PageCache::__construct public function Constructs a PageCache object.