class SiteCacheContext
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php \Drupal\Core\Cache\Context\SiteCacheContext
- 10 core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php \Drupal\Core\Cache\Context\SiteCacheContext
Defines the SiteCacheContext service, for "per site" caching.
Cache context ID: 'url.site'.
A "site" is defined as the combination of URI scheme, domain name, port and base path. It allows for varying between the *same* site being accessed via different entry points. (Different sites in a multisite setup have separate databases.) For example: http://example.com and http://www.example.com.
Hierarchy
- class \Drupal\Core\Cache\Context\RequestStackCacheContextBase
- class \Drupal\Core\Cache\Context\SiteCacheContext extends \Drupal\Core\Cache\Context\CacheContextInterface implements \Drupal\Core\Cache\Context\RequestStackCacheContextBase
Expanded class hierarchy of SiteCacheContext
See also
\Symfony\Component\HttpFoundation\Request::getSchemeAndHttpHost()
\Symfony\Component\HttpFoundation\Request::getBaseUrl()
1 string reference to 'SiteCacheContext'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses SiteCacheContext
File
-
core/
lib/ Drupal/ Core/ Cache/ Context/ SiteCacheContext.php, line 20
Namespace
Drupal\Core\Cache\ContextView source
class SiteCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Site');
}
/**
* {@inheritdoc}
*/
public function getContext() {
$request = $this->requestStack
->getCurrentRequest();
return $request->getSchemeAndHttpHost() . $request->getBaseUrl();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.