Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / RouteCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Routing\RouteMatchInterface;
7
8 /**
9  * Defines the RouteCacheContext service, for "per route" caching.
10  *
11  * Cache context ID: 'route'.
12  */
13 class RouteCacheContext implements CacheContextInterface {
14
15   /**
16    * The route match.
17    *
18    * @var \Drupal\Core\Routing\RouteMatchInterface
19    */
20   protected $routeMatch;
21
22   /**
23    * Constructs a new RouteCacheContext class.
24    *
25    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
26    *   The route match.
27    */
28   public function __construct(RouteMatchInterface $route_match) {
29     $this->routeMatch = $route_match;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public static function getLabel() {
36     return t('Route');
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getContext() {
43     return $this->routeMatch->getRouteName() . hash('sha256', serialize($this->routeMatch->getRawParameters()->all()));
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   public function getCacheableMetadata() {
50     return new CacheableMetadata();
51   }
52
53 }