3 namespace Drupal\Core\Cache\Context;
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Routing\RouteMatchInterface;
9 * Defines the RouteCacheContext service, for "per route" caching.
11 * Cache context ID: 'route'.
13 class RouteCacheContext implements CacheContextInterface {
18 * @var \Drupal\Core\Routing\RouteMatchInterface
20 protected $routeMatch;
23 * Constructs a new RouteCacheContext class.
25 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
28 public function __construct(RouteMatchInterface $route_match) {
29 $this->routeMatch = $route_match;
35 public static function getLabel() {
42 public function getContext() {
43 return $this->routeMatch->getRouteName() . hash('sha256', serialize($this->routeMatch->getRawParameters()->all()));
49 public function getCacheableMetadata() {
50 return new CacheableMetadata();