Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / IpCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6
7 /**
8  * Defines the IpCacheContext service, for "per IP address" caching.
9  *
10  * Cache context ID: 'ip'.
11  */
12 class IpCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static function getLabel() {
18     return t('IP address');
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getContext() {
25     return $this->requestStack->getCurrentRequest()->getClientIp();
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getCacheableMetadata() {
32     return new CacheableMetadata();
33   }
34
35 }