CookiesCacheContext.php in Drupal 9
File
core/lib/Drupal/Core/Cache/Context/CookiesCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
class CookiesCacheContext extends RequestStackCacheContextBase implements CalculatedCacheContextInterface {
public static function getLabel() {
return t('HTTP cookies');
}
public function getContext($cookie = NULL) {
if ($cookie === NULL) {
return $this->requestStack
->getCurrentRequest()->cookies
->all();
}
else {
return $this->requestStack
->getCurrentRequest()->cookies
->get($cookie);
}
}
public function getCacheableMetadata($cookie = NULL) {
return new CacheableMetadata();
}
}