Commit 8305be48 authored by xjm's avatar xjm

Issue #2483781 by borisson_, rbayliss, cilefen, mitalimehta, joshi.rohit100:...

Issue #2483781 by borisson_, rbayliss, cilefen, mitalimehta, joshi.rohit100: Move cache contexts classes from \Drupal\Core\Cache to \Drupal\Core\Cache\Context
parent 41560b32
...@@ -10,59 +10,59 @@ parameters: ...@@ -10,59 +10,59 @@ parameters:
services: services:
# Simple cache contexts, directly derived from the request context. # Simple cache contexts, directly derived from the request context.
cache_context.ip: cache_context.ip:
class: Drupal\Core\Cache\IpCacheContext class: Drupal\Core\Cache\Context\IpCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.headers: cache_context.headers:
class: Drupal\Core\Cache\HeadersCacheContext class: Drupal\Core\Cache\Context\HeadersCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.cookies: cache_context.cookies:
class: Drupal\Core\Cache\CookiesCacheContext class: Drupal\Core\Cache\Context\CookiesCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.request_format: cache_context.request_format:
class: Drupal\Core\Cache\RequestFormatCacheContext class: Drupal\Core\Cache\Context\RequestFormatCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.url: cache_context.url:
class: Drupal\Core\Cache\UrlCacheContext class: Drupal\Core\Cache\Context\UrlCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.url.site: cache_context.url.site:
class: Drupal\Core\Cache\SiteCacheContext class: Drupal\Core\Cache\Context\SiteCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.url.query_args: cache_context.url.query_args:
class: Drupal\Core\Cache\QueryArgsCacheContext class: Drupal\Core\Cache\Context\QueryArgsCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.url.query_args.pagers: cache_context.url.query_args.pagers:
class: Drupal\Core\Cache\PagersCacheContext class: Drupal\Core\Cache\Context\PagersCacheContext
arguments: ['@request_stack'] arguments: ['@request_stack']
tags: tags:
- { name: cache.context } - { name: cache.context }
# Complex cache contexts, that depend on the routing system. # Complex cache contexts, that depend on the routing system.
cache_context.route: cache_context.route:
class: Drupal\Core\Cache\RouteCacheContext class: Drupal\Core\Cache\Context\RouteCacheContext
arguments: ['@current_route_match'] arguments: ['@current_route_match']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.route.name: cache_context.route.name:
class: Drupal\Core\Cache\RouteNameCacheContext class: Drupal\Core\Cache\Context\RouteNameCacheContext
arguments: ['@current_route_match'] arguments: ['@current_route_match']
tags: tags:
- { name: cache.context } - { name: cache.context }
cache_context.route.menu_active_trails: cache_context.route.menu_active_trails:
class: Drupal\Core\Cache\MenuActiveTrailsCacheContext class: Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext
calls: calls:
- [setContainer, ['@service_container']] - [setContainer, ['@service_container']]
tags: tags:
...@@ -72,37 +72,37 @@ services: ...@@ -72,37 +72,37 @@ services:
# multiple aspects of the request context plus additional logic. Hence they # multiple aspects of the request context plus additional logic. Hence they
# are their own roots. # are their own roots.
cache_context.user: cache_context.user:
class: Drupal\Core\Cache\UserCacheContext class: Drupal\Core\Cache\Context\UserCacheContext
arguments: ['@current_user'] arguments: ['@current_user']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.user.permissions: cache_context.user.permissions:
class: Drupal\Core\Cache\AccountPermissionsCacheContext class: Drupal\Core\Cache\Context\AccountPermissionsCacheContext
arguments: ['@current_user', '@user_permissions_hash_generator'] arguments: ['@current_user', '@user_permissions_hash_generator']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.user.roles: cache_context.user.roles:
class: Drupal\Core\Cache\UserRolesCacheContext class: Drupal\Core\Cache\Context\UserRolesCacheContext
arguments: ['@current_user'] arguments: ['@current_user']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.user.is_super_user: cache_context.user.is_super_user:
class: Drupal\Core\Cache\IsSuperUserCacheContext class: Drupal\Core\Cache\Context\IsSuperUserCacheContext
arguments: ['@current_user'] arguments: ['@current_user']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.languages: cache_context.languages:
class: Drupal\Core\Cache\LanguagesCacheContext class: Drupal\Core\Cache\Context\LanguagesCacheContext
arguments: ['@language_manager'] arguments: ['@language_manager']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.theme: cache_context.theme:
class: Drupal\Core\Cache\ThemeCacheContext class: Drupal\Core\Cache\Context\ThemeCacheContext
arguments: ['@theme.manager'] arguments: ['@theme.manager']
tags: tags:
- { name: cache.context} - { name: cache.context}
cache_context.timezone: cache_context.timezone:
class: Drupal\Core\Cache\TimeZoneCacheContext class: Drupal\Core\Cache\Context\TimeZoneCacheContext
tags: tags:
- { name: cache.context} - { name: cache.context}
...@@ -112,7 +112,7 @@ services: ...@@ -112,7 +112,7 @@ services:
calls: calls:
- [setContainer, ['@service_container']] - [setContainer, ['@service_container']]
cache_contexts_manager: cache_contexts_manager:
class: Drupal\Core\Cache\CacheContextsManager class: Drupal\Core\Cache\Context\CacheContextsManager
arguments: ['@service_container', '%cache_contexts%' ] arguments: ['@service_container', '%cache_contexts%' ]
cache_tags.invalidator: cache_tags.invalidator:
parent: container.trait parent: container.trait
......
...@@ -31,8 +31,8 @@ abstract class AccessResult implements AccessResultInterface, CacheableDependenc ...@@ -31,8 +31,8 @@ abstract class AccessResult implements AccessResultInterface, CacheableDependenc
/** /**
* The cache context IDs (to vary a cache item ID based on active contexts). * The cache context IDs (to vary a cache item ID based on active contexts).
* *
* @see \Drupal\Core\Cache\CacheContextInterface * @see \Drupal\Core\Cache\Context\CacheContextInterface
* @see \Drupal\Core\Cache\CacheContextsManager::convertTokensToKeys() * @see \Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()
* *
* @var string[] * @var string[]
*/ */
......
...@@ -31,7 +31,7 @@ interface CacheableDependencyInterface { ...@@ -31,7 +31,7 @@ interface CacheableDependencyInterface {
* @return string[] * @return string[]
* An array of cache context tokens, used to generate a cache ID. * An array of cache context tokens, used to generate a cache ID.
* *
* @see \Drupal\Core\Cache\CacheContextsManager::convertTokensToKeys() * @see \Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()
*/ */
public function getCacheContexts(); public function getCacheContexts();
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\UserRolesCacheContext. * Contains \Drupal\Core\Cache\Context\UserRolesCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\PermissionsHashGeneratorInterface; use Drupal\Core\Session\PermissionsHashGeneratorInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\CacheContextInterface. * Contains \Drupal\Core\Cache\Context\CacheContextInterface.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Provides an interface for defining a cache context service. * Provides an interface for defining a cache context service.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\CacheContextsManager. * Contains \Drupal\Core\Cache\Context\CacheContextsManager.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
* Note that this maps exactly to HTTP's Vary header semantics: * Note that this maps exactly to HTTP's Vary header semantics:
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44 * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44
* *
* @see \Drupal\Core\Cache\CacheContextInterface * @see \Drupal\Core\Cache\Context\CacheContextInterface
* @see \Drupal\Core\Cache\CalculatedCacheContextInterface * @see \Drupal\Core\Cache\Context\CalculatedCacheContextInterface
* @see \Drupal\Core\Cache\CacheContextsPass * @see \Drupal\Core\Cache\Context\CacheContextsPass
*/ */
class CacheContextsManager { class CacheContextsManager {
...@@ -188,7 +188,7 @@ public function optimizeTokens(array $context_tokens) { ...@@ -188,7 +188,7 @@ public function optimizeTokens(array $context_tokens) {
* The context ID, which together with the service ID prefix allows the * The context ID, which together with the service ID prefix allows the
* corresponding cache context service to be retrieved. * corresponding cache context service to be retrieved.
* *
* @return \Drupal\Core\Cache\CacheContextInterface * @return \Drupal\Core\Cache\Context\CacheContextInterface
* The requested cache context service. * The requested cache context service.
*/ */
protected function getService($context_id) { protected function getService($context_id) {
...@@ -231,7 +231,7 @@ public static function parseTokens(array $context_tokens) { ...@@ -231,7 +231,7 @@ public static function parseTokens(array $context_tokens) {
* *
* @throws \LogicException * @throws \LogicException
* *
* @see \Drupal\Core\Cache\CacheContextsManager::parseTokens() * @see \Drupal\Core\Cache\Context\CacheContextsManager::parseTokens()
*/ */
public function validateTokens(array $context_tokens = []) { public function validateTokens(array $context_tokens = []) {
if (empty($context_tokens)) { if (empty($context_tokens)) {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\CacheContextsPass. * Contains \Drupal\Core\Cache\Context\CacheContextsPass.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\CacheContextInterface. * Contains \Drupal\Core\Cache\Context\CacheContextInterface.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Provides an interface for defining a calculated cache context service. * Provides an interface for defining a calculated cache context service.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\CookiesCacheContext. * Contains \Drupal\Core\Cache\Context\CookiesCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the CookiesCacheContext service, for "per cookie" caching. * Defines the CookiesCacheContext service, for "per cookie" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\HeadersCacheContext. * Contains \Drupal\Core\Cache\Context\HeadersCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the HeadersCacheContext service, for "per header" caching. * Defines the HeadersCacheContext service, for "per header" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\IpCacheContext. * Contains \Drupal\Core\Cache\Context\IpCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the IpCacheContext service, for "per IP address" caching. * Defines the IpCacheContext service, for "per IP address" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\IsSuperUserCacheContext. * Contains \Drupal\Core\Cache\Context\IsSuperUserCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the IsSuperUserCacheContext service, for "super user or not" caching. * Defines the IsSuperUserCacheContext service, for "super user or not" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\LanguagesCacheContext. * Contains \Drupal\Core\Cache\Context\LanguagesCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\MenuActiveTrailsCacheContext. * Contains \Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\DependencyInjection\ContainerAware;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\PagersCacheContext. * Contains \Drupal\Core\Cache\Context\PagersCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines a cache context for "per page in a pager" caching. * Defines a cache context for "per page in a pager" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\QueryArgsCacheContext. * Contains \Drupal\Core\Cache\Context\QueryArgsCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the QueryArgsCacheContext service, for "per query args" caching. * Defines the QueryArgsCacheContext service, for "per query args" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\RequestFormatCacheContext. * Contains \Drupal\Core\Cache\Context\RequestFormatCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the RequestFormatCacheContext service, for "per format" caching. * Defines the RequestFormatCacheContext service, for "per format" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\RequestStackCacheContextBase. * Contains \Drupal\Core\Cache\Context\RequestStackCacheContextBase.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\RouteCacheContext. * Contains \Drupal\Core\Cache\Context\RouteCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\RouteNameCacheContext. * Contains \Drupal\Core\Cache\Context\RouteNameCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the RouteCacheContext service, for "per route name" caching. * Defines the RouteCacheContext service, for "per route name" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\SiteCacheContext. * Contains \Drupal\Core\Cache\Context\SiteCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the SiteCacheContext service, for "per site" caching. * Defines the SiteCacheContext service, for "per site" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\LanguageCacheContext. * Contains \Drupal\Core\Cache\Context\LanguageCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeManagerInterface; use Drupal\Core\Theme\ThemeManagerInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\TimeZoneCacheContext. * Contains \Drupal\Core\Cache\Context\TimeZoneCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the TimeZoneCacheContext service, for "per time zone" caching. * Defines the TimeZoneCacheContext service, for "per time zone" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\UrlCacheContext. * Contains \Drupal\Core\Cache\Context\UrlCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the UrlCacheContext service, for "per page" caching. * Defines the UrlCacheContext service, for "per page" caching.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\UserCacheContext. * Contains \Drupal\Core\Cache\Context\UserCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Cache\UserRolesCacheContext. * Contains \Drupal\Core\Cache\Context\UserRolesCacheContext.
*/ */
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache\Context;
/** /**
* Defines the UserRolesCacheContext service, for "per role" caching. * Defines the UserRolesCacheContext service, for "per role" caching.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\Core; namespace Drupal\Core;
use Drupal\Core\Cache\CacheContextsPass; use Drupal\Core\Cache\Context\CacheContextsPass;
use Drupal\Core\Cache\ListCacheBinsPass; use Drupal\Core\Cache\ListCacheBinsPass;
use Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass;