Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / SiteCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6
7 /**
8  * Defines the SiteCacheContext service, for "per site" caching.
9  *
10  * Cache context ID: 'site'.
11  *
12  * A "site" is defined as the combination of URI scheme, domain name, port and
13  * base path. It allows for varying between the *same* site being accessed via
14  * different entry points. (Different sites in a multisite setup have separate
15  * databases.) For example: http://example.com and http://www.example.com.
16  *
17  * @see \Symfony\Component\HttpFoundation\Request::getSchemeAndHttpHost()
18  * @see \Symfony\Component\HttpFoundation\Request::getBaseUrl()
19  */
20 class SiteCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public static function getLabel() {
26     return t('Site');
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function getContext() {
33     $request = $this->requestStack->getCurrentRequest();
34     return $request->getSchemeAndHttpHost() . $request->getBaseUrl();
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getCacheableMetadata() {
41     return new CacheableMetadata();
42   }
43
44 }