Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Cache/Context/SessionExistsCacheContext.php
- 9 core/lib/Drupal/Core/Cache/Context/SessionExistsCacheContext.php
Namespace
Drupal\Core\Cache\Context
File
core/lib/Drupal/Core/Cache/Context/SessionExistsCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Session\SessionConfigurationInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class SessionExistsCacheContext implements CacheContextInterface {
protected $sessionConfiguration;
protected $requestStack;
public function __construct(SessionConfigurationInterface $session_configuration, RequestStack $request_stack) {
$this->sessionConfiguration = $session_configuration;
$this->requestStack = $request_stack;
}
public static function getLabel() {
return t('Session exists');
}
public function getContext() {
return $this->sessionConfiguration
->hasSession($this->requestStack
->getCurrentRequest()) ? '1' : '0';
}
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Classes