Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 11 |
HeadersCacheContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 11 |
getLabel | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getContext | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 7 |
|||
getCacheableMetadata | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\Core\Cache\Context\HeadersCacheContext. | |
*/ | |
namespace Drupal\Core\Cache\Context; | |
use Drupal\Core\Cache\CacheableMetadata; | |
/** | |
* Defines the HeadersCacheContext service, for "per header" caching. | |
* | |
* Cache context ID: 'headers' (to vary by all headers). | |
* Calculated cache context ID: 'headers:%name', e.g. 'headers:X-Something' (to | |
* vary by the 'X-Something' header). | |
*/ | |
class HeadersCacheContext extends RequestStackCacheContextBase implements CalculatedCacheContextInterface { | |
/** | |
* {@inheritdoc} | |
*/ | |
public static function getLabel() { | |
return t('HTTP headers'); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getContext($header = NULL) { | |
if ($header === NULL) { | |
return $this->requestStack->getCurrentRequest()->headers->all(); | |
} | |
else { | |
return $this->requestStack->getCurrentRequest()->headers->get($header); | |
} | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getCacheableMetadata($header = NULL) { | |
return new CacheableMetadata(); | |
} | |
} |