class DomainRouteProvider in Domain Access 8
Custom router.route_provider service to make it domain context sensitive.
The default behaviour is to cache routes by path and query parameters only, for multiple domains this can make the home page of domain 1 be served from cache as the home page of domain 2.
Originally used by Domain Config, this behavior is tested in domain_config/tests/src/Functional/DomainConfigHomepageTest.php.
We have moved the behavior to the main module to better support extension modules that do not require Domain Config, such as Domain Path.
Hierarchy
- class \Drupal\Core\Routing\RouteProvider implements \Symfony\Cmf\Component\Routing\PagedRouteProviderInterface, \Symfony\Component\EventDispatcher\EventSubscriberInterface, CacheableRouteProviderInterface, PreloadableRouteProviderInterface
- class \Drupal\domain\Routing\DomainRouteProvider
Expanded class hierarchy of DomainRouteProvider
1 string reference to 'DomainRouteProvider'
- domain.services.yml in domain/
domain.services.yml - domain/domain.services.yml
1 service uses DomainRouteProvider
File
- domain/
src/ Routing/ DomainRouteProvider.php, line 28
Namespace
Drupal\domain\RoutingView source
class DomainRouteProvider extends RouteProvider {
/**
* DomainRouteProvider constructor.
*
* Extends the core RouteProvider. Note that the Kernel tests load a
* different RouteProvider, which means we cannot declare a common interface
* for the $inner_service parameter.
*
* @see Drupal\Core\Routing\RouteProvider::__construct()
*/
public function __construct($inner_service, Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $table = 'router', LanguageManagerInterface $language_manager = NULL) {
$this->innerService = $inner_service;
parent::__construct($connection, $state, $current_path, $cache_backend, $path_processor, $cache_tag_invalidator, $table, $language_manager);
}
/**
* Returns the cache ID for the route collection cache.
*
* We are overriding the cache id by inserting the host to the cid.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @see \Drupal\Core\Routing\RouteProvider::getRouteCollectionCacheId()
*
* @return string
* The cache ID.
*/
protected function getRouteCollectionCacheId(Request $request) {
// Include the current language code in the cache identifier as
// the language information can be elsewhere than in the path, for example
// based on the domain.
$language_part = $this
->getCurrentLanguageCacheIdPart();
return 'route:' . $request
->getHost() . ':' . $language_part . ':' . $request
->getPathInfo() . ':' . $request
->getQueryString();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DomainRouteProvider:: |
protected | function |
Returns the cache ID for the route collection cache. Overrides RouteProvider:: |
|
DomainRouteProvider:: |
public | function |
DomainRouteProvider constructor. Overrides RouteProvider:: |
|
RouteProvider:: |
protected | property | The cache backend. | |
RouteProvider:: |
protected | property | The cache tag invalidator. | |
RouteProvider:: |
protected | property | The database connection from which to read route information. | |
RouteProvider:: |
protected | property | The current path. | |
RouteProvider:: |
protected | property | An array of cache key parts to be used for the route match cache. | |
RouteProvider:: |
protected | property | The language manager. | |
RouteProvider:: |
protected | property | A path processor manager for resolving the system path. | |
RouteProvider:: |
protected | property | A cache of already-loaded routes, keyed by route name. | |
RouteProvider:: |
protected | property | A cache of already-loaded serialized routes, keyed by route name. | |
RouteProvider:: |
protected | property | The state. | |
RouteProvider:: |
protected | property | The name of the SQL table from which to read the routes. | |
RouteProvider:: |
public | function |
Adds a cache key part to be used in the cache ID of the route collection. Overrides CacheableRouteProviderInterface:: |
|
RouteProvider:: |
public | function |
Returns all the routes on the system. Overrides RouteProviderInterface:: |
|
RouteProvider:: |
protected | function | Returns an array of path pattern outlines that could match the path parts. | 1 |
RouteProvider:: |
protected | function | Returns the language identifier for the route collection cache. | |
RouteProvider:: |
public | function | Find the route using the provided route name. | |
RouteProvider:: |
public | function | Finds routes that may potentially match the request. | |
RouteProvider:: |
public | function | Find many routes by their names using the provided list of names. | |
RouteProvider:: |
protected | function | Get all routes which match a certain pattern. | |
RouteProvider:: |
public | function |
Get all routes which match a certain pattern. Overrides RouteProviderInterface:: |
|
RouteProvider:: |
public | function | Determines the total amount of routes. | |
RouteProvider:: |
public | function | Find an amount of routes with an offset and possible a limit. | |
RouteProvider:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
RouteProvider:: |
public | function |
Pre-load routes by their names using the provided list of names. Overrides PreloadableRouteProviderInterface:: |
|
RouteProvider:: |
public | function |
Resets the route provider object. Overrides RouteProviderInterface:: |
|
RouteProvider:: |
protected | function | Comparison function for usort on routes. | |
RouteProvider:: |
constant | Cache ID prefix used to load routes. |