Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / SessionCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Component\Utility\Crypt;
6
7 /**
8  * Defines the SessionCacheContext service, for "per session" caching.
9  *
10  * Cache context ID: 'session'.
11  */
12 class SessionCacheContext extends RequestStackCacheContextBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static function getLabel() {
18     return t('Session');
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getContext() {
25     $request = $this->requestStack->getCurrentRequest();
26     if ($request->hasSession()) {
27       return Crypt::hashBase64($request->getSession()->getId());
28     }
29     return 'none';
30   }
31
32 }