class RouteProvider in Multiversion 8
Overrides core RouteProvider.
Hierarchy
- class \Drupal\Core\Routing\RouteProvider implements \Symfony\Cmf\Component\Routing\PagedRouteProviderInterface, \Symfony\Component\EventDispatcher\EventSubscriberInterface, CacheableRouteProviderInterface, PreloadableRouteProviderInterface
- class \Drupal\multiversion\RouteProvider
Expanded class hierarchy of RouteProvider
1 string reference to 'RouteProvider'
1 service uses RouteProvider
File
- src/
RouteProvider.php, line 19
Namespace
Drupal\multiversionView source
class RouteProvider extends CoreRouteProvider {
/**
* The workspace manager.
*
* @var \Drupal\multiversion\Workspace\WorkspaceManagerInterface
*/
private $workspaceManager;
/**
* {@inheritdoc}
*/
public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, CacheBackendInterface $cache_backend, InboundPathProcessorInterface $path_processor, CacheTagsInvalidatorInterface $cache_tag_invalidator, $table = 'router', LanguageManagerInterface $language_manager = NULL, WorkspaceManagerInterface $workspace_manager) {
// @todo Remove this when Multiversion requires Drupal 8.5 or newer.
if (floatval(\Drupal::VERSION) < 8.5) {
parent::__construct($connection, $state, $current_path, $cache_backend, $path_processor, $cache_tag_invalidator, $table);
}
else {
parent::__construct($connection, $state, $current_path, $cache_backend, $path_processor, $cache_tag_invalidator, $table, $language_manager);
}
$this->workspaceManager = $workspace_manager;
}
/**
* {@inheritdoc}
*/
public function getRouteCollectionForRequest(Request $request) {
// Cache both the system path as well as route parameters and matching
// routes.
$workspace_id = $this->workspaceManager
->getActiveWorkspaceId();
// @todo Remove this when Multiversion requires Drupal 8.5 or newer.
if (!method_exists($this, 'getCurrentLanguageCacheIdPart')) {
$cid = 'route:' . "workspace{$workspace_id}:" . $request
->getPathInfo() . ':' . $request
->getQueryString();
}
else {
$language_part = $this
->getCurrentLanguageCacheIdPart();
$cid = 'route:' . "workspace{$workspace_id}:" . "{$language_part}:" . $request
->getPathInfo() . ':' . $request
->getQueryString();
}
if ($cached = $this->cache
->get($cid)) {
$this->currentPath
->setPath($cached->data['path'], $request);
$request->query
->replace($cached->data['query']);
return $cached->data['routes'];
}
else {
// Just trim on the right side.
$path = $request
->getPathInfo();
$path = $path === '/' ? $path : rtrim($request
->getPathInfo(), '/');
$path = $this->pathProcessor
->processInbound($path, $request);
$this->currentPath
->setPath($path, $request);
// Incoming path processors may also set query parameters.
$query_parameters = $request->query
->all();
$routes = $this
->getRoutesByPath(rtrim($path, '/'));
$cache_value = [
'path' => $path,
'query' => $query_parameters,
'routes' => $routes,
];
$this->cache
->set($cid, $cache_value, CacheBackendInterface::CACHE_PERMANENT, [
'route_match',
]);
return $routes;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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:: |
private | property | The workspace manager. | |
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:: |
protected | function | Returns the cache ID for the route collection cache. | |
RouteProvider:: |
public | function |
Finds routes that may potentially match the request. Overrides RouteProvider:: |
|
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. | ||
RouteProvider:: |
public | function |
Constructs a new PathMatcher. Overrides RouteProvider:: |