Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 8 |
RouteCacheContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 8 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getLabel | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getContext | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getCacheableMetadata | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\Core\Cache\Context\RouteCacheContext. | |
*/ | |
namespace Drupal\Core\Cache\Context; | |
use Drupal\Core\Cache\CacheableMetadata; | |
use Drupal\Core\Routing\RouteMatchInterface; | |
/** | |
* Defines the RouteCacheContext service, for "per route" caching. | |
* | |
* Cache context ID: 'route'. | |
*/ | |
class RouteCacheContext implements CacheContextInterface { | |
/** | |
* The route match. | |
* | |
* @var \Drupal\Core\Routing\RouteMatchInterface | |
*/ | |
protected $routeMatch; | |
/** | |
* Constructs a new RouteCacheContext class. | |
* | |
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match | |
* The route match. | |
*/ | |
public function __construct(RouteMatchInterface $route_match) { | |
$this->routeMatch = $route_match; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public static function getLabel() { | |
return t('Route'); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getContext() { | |
return $this->routeMatch->getRouteName() . hash('sha256', serialize($this->routeMatch->getRawParameters()->all())); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getCacheableMetadata() { | |
return new CacheableMetadata(); | |
} | |
} |