RouteCacheContext.php in Drupal 10
File
core/lib/Drupal/Core/Cache/Context/RouteCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Routing\RouteMatchInterface;
class RouteCacheContext implements CacheContextInterface {
protected $routeMatch;
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
public static function getLabel() {
return t('Route');
}
public function getContext() {
return $this->routeMatch
->getRouteName() . hash('sha256', serialize($this->routeMatch
->getRawParameters()
->all()));
}
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}