Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / PathCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6
7 /**
8  * Defines the PathCacheContext service, for "per URL path" caching.
9  *
10  * Cache context ID: 'url.path'.
11  *
12  * (This allows for caching relative URLs.)
13  *
14  * @see \Symfony\Component\HttpFoundation\Request::getBasePath()
15  * @see \Symfony\Component\HttpFoundation\Request::getPathInfo()
16  */
17 class PathCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
18
19   /**
20    * {@inheritdoc}
21    */
22   public static function getLabel() {
23     return t('Path');
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   public function getContext() {
30     $request = $this->requestStack->getCurrentRequest();
31     return $request->getBasePath() . $request->getPathInfo();
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function getCacheableMetadata() {
38     return new CacheableMetadata();
39   }
40
41 }