Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\Access\AccessInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing\Access;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\AccessAwareRouter.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Access\AccessManagerInterface;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\AccessAwareRouterInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\AdminContext.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\CacheableSecuredRedirectResponse.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Component\HttpFoundation\SecuredRedirectResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\CompiledRoute.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\CompiledRoute as SymfonyCompiledRoute;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\ContentTypeHeaderMatcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\CurrentRouteMatch.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -13,7 +8,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
|||
/**
|
||||
* Default object for current_route_match service.
|
||||
*/
|
||||
class CurrentRouteMatch implements RouteMatchInterface, StackedRouteMatchInterface {
|
||||
class CurrentRouteMatch implements ResettableStackedRouteMatchInterface {
|
||||
|
||||
/**
|
||||
* The related request stack.
|
||||
|
@ -33,7 +28,7 @@ class CurrentRouteMatch implements RouteMatchInterface, StackedRouteMatchInterfa
|
|||
* Constructs a CurrentRouteMatch object.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
|
||||
* The request stack.
|
||||
* The request stack.
|
||||
*/
|
||||
public function __construct(RequestStack $request_stack) {
|
||||
$this->requestStack = $request_stack;
|
||||
|
@ -118,6 +113,13 @@ class CurrentRouteMatch implements RouteMatchInterface, StackedRouteMatchInterfa
|
|||
return $route_match;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resetRouteMatch() {
|
||||
$this->routeMatches = new \SplObjectStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Routing\Enhancer;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Adds _entity_revision to the request attributes, if possible.
|
||||
*/
|
||||
class EntityRevisionRouteEnhancer implements RouteEnhancerInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies(Route $route) {
|
||||
// Check whether there is any entity revision parameter.
|
||||
$parameters = $route->getOption('parameters') ?: [];
|
||||
foreach ($parameters as $info) {
|
||||
if (isset($info['type']) && strpos($info['type'], 'entity_revision:') === 0) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request) {
|
||||
/** @var \Symfony\Component\Routing\Route $route */
|
||||
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
|
||||
$options = $route->getOptions();
|
||||
if (isset($options['parameters'])) {
|
||||
foreach ($options['parameters'] as $name => $details) {
|
||||
if (!empty($details['type']) && strpos($details['type'], 'entity_revision:') !== FALSE) {
|
||||
$defaults['_entity_revision'] = $defaults[$name];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\Enhancer\FormRouteEnhancer.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing\Enhancer;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing\Enhancer;
|
||||
|
||||
use Drupal\Core\ParamConverter\ParamConverterManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\Enhancer\RouteEnhancerInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing\Enhancer;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface as BaseRouteEnhancerInterface;
|
||||
|
@ -19,7 +14,7 @@ interface RouteEnhancerInterface extends BaseRouteEnhancerInterface {
|
|||
* Declares if the route enhancer applies to the given route.
|
||||
*
|
||||
* @param \Symfony\Component\Routing\Route $route
|
||||
* The route to consider attaching to.
|
||||
* The route to consider attaching to.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the check applies to the passed route, False otherwise.
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\GeneratorNotInitializedException.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\LazyRouteEnhancer.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\LazyRouteFilter.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface as BaseRouteFilterInterface;
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\LinkGeneratorTrait.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Link instead.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
|
||||
|
@ -21,6 +13,9 @@ use Drupal\Core\Utility\LinkGeneratorInterface;
|
|||
* classes that would implement ContainerInjectionInterface. Services registered
|
||||
* in the Container should not use this trait but inject the appropriate service
|
||||
* directly for easier testing.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Link instead.
|
||||
*/
|
||||
trait LinkGeneratorTrait {
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\LocalAwareRedirectResponseTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\LocalRedirectResponse.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\MatcherDumper.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Database\SchemaObjectExistsException;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
|
@ -14,6 +10,8 @@ use Drupal\Core\Database\Connection;
|
|||
|
||||
/**
|
||||
* Dumps Route information to a database table.
|
||||
*
|
||||
* @see \Drupal\Core\Routing\RouteProvider
|
||||
*/
|
||||
class MatcherDumper implements MatcherDumperInterface {
|
||||
|
||||
|
@ -97,7 +95,13 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
try {
|
||||
// We don't use truncate, because it is not guaranteed to be transaction
|
||||
// safe.
|
||||
$this->connection->delete($this->tableName)->execute();
|
||||
try {
|
||||
$this->connection->delete($this->tableName)
|
||||
->execute();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->ensureTableExists();
|
||||
}
|
||||
|
||||
// Split the routes into chunks to avoid big INSERT queries.
|
||||
$route_chunks = array_chunk($this->routes->all(), 50, TRUE);
|
||||
|
@ -162,4 +166,85 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
return $this->routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the tree table exists and create it if not.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the table was created, FALSE otherwise.
|
||||
*/
|
||||
protected function ensureTableExists() {
|
||||
try {
|
||||
if (!$this->connection->schema()->tableExists($this->tableName)) {
|
||||
$this->connection->schema()->createTable($this->tableName, $this->schemaDefinition());
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch (SchemaObjectExistsException $e) {
|
||||
// If another process has already created the config table, attempting to
|
||||
// recreate it will throw an exception. In this case just catch the
|
||||
// exception and do nothing.
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the schema for the router table.
|
||||
*
|
||||
* @return array
|
||||
* The schema API definition for the SQL storage table.
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema = [
|
||||
'description' => 'Maps paths to various callbacks (access, page and title)',
|
||||
'fields' => [
|
||||
'name' => [
|
||||
'description' => 'Primary Key: Machine name of this route',
|
||||
'type' => 'varchar_ascii',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
],
|
||||
'path' => [
|
||||
'description' => 'The path for this URI',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
],
|
||||
'pattern_outline' => [
|
||||
'description' => 'The pattern',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
],
|
||||
'fit' => [
|
||||
'description' => 'A numeric representation of how specific the path is.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
],
|
||||
'route' => [
|
||||
'description' => 'A serialized Route object',
|
||||
'type' => 'blob',
|
||||
'size' => 'big',
|
||||
],
|
||||
'number_parts' => [
|
||||
'description' => 'Number of parts in this router path.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'small',
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'pattern_outline_parts' => ['pattern_outline', 'number_parts'],
|
||||
],
|
||||
'primary key' => ['name'],
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\MatcherDumperInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface as SymfonyMatcherDumperInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\MatchingRouteNotFoundException.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\NullGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\NullMatcherDumper.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\NullRouteMatch.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\PreloadableRouteProviderInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RedirectDestination.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RedirectDestinationInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RedirectDestinationTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RequestContext.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RequestFormatRouteFilter.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RequestHelper.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
* Defines an interface for a resettable stack of route matches.
|
||||
*
|
||||
* @todo Move this method to \Drupal\Core\Routing\StackedRouteMatchInterface in
|
||||
* https://www.drupal.org/node/2659952.
|
||||
*/
|
||||
interface ResettableStackedRouteMatchInterface extends StackedRouteMatchInterface {
|
||||
|
||||
/**
|
||||
* Resets the route match static cache.
|
||||
*
|
||||
* The route match should only be statically cached once routing is finished.
|
||||
* Any code that uses a route match during routing may be incorrectly assumed
|
||||
* to be acting after routing has completed. This method gives that code the
|
||||
* ability to fix the static cache.
|
||||
*/
|
||||
public function resetRouteMatch();
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteBuildEvent.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Component\Discovery\YamlDiscovery;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteBuilderInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
interface RouteBuilderInterface {
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteCompiler.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\Routing\RouteCompilerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteFilterInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface as BaseRouteFilterInterface;
|
||||
|
@ -19,7 +14,7 @@ interface RouteFilterInterface extends BaseRouteFilterInterface {
|
|||
* Determines if the route filter applies to the given route.
|
||||
*
|
||||
* @param \Symfony\Component\Routing\Route $route
|
||||
* The route to consider attaching to.
|
||||
* The route to consider attaching to.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the check applies to the passed route, FALSE otherwise.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteMatch.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
@ -49,7 +44,7 @@ class RouteMatch implements RouteMatchInterface {
|
|||
* Constructs a RouteMatch object.
|
||||
*
|
||||
* @param string $route_name
|
||||
* The name of the route.
|
||||
* The name of the route.
|
||||
* @param \Symfony\Component\Routing\Route $route
|
||||
* The route.
|
||||
* @param array $parameters
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteMatchInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RoutePreloader.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
@ -210,7 +205,12 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
|
|||
$routes = $cache->data;
|
||||
}
|
||||
else {
|
||||
$result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', array(':names[]' => $routes_to_load));
|
||||
try {
|
||||
$result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', array(':names[]' => $routes_to_load));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$result = [];
|
||||
}
|
||||
$routes = $result->fetchAllKeyed();
|
||||
|
||||
$this->cache->set($cid, $routes, Cache::PERMANENT, ['routes']);
|
||||
|
@ -336,10 +336,15 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
|
|||
// The >= check on number_parts allows us to match routes with optional
|
||||
// trailing wildcard parts as long as the pattern matches, since we
|
||||
// dump the route pattern without those optional parts.
|
||||
$routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", array(
|
||||
':patterns[]' => $ancestors, ':count_parts' => count($parts),
|
||||
))
|
||||
->fetchAll(\PDO::FETCH_ASSOC);
|
||||
try {
|
||||
$routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", array(
|
||||
':patterns[]' => $ancestors, ':count_parts' => count($parts),
|
||||
))
|
||||
->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$routes = [];
|
||||
}
|
||||
|
||||
// We sort by fit and name in PHP to avoid a SQL filesort.
|
||||
usort($routes, array($this, 'routeProviderRouteCompare'));
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteProviderInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteProviderInterface as RouteProviderBaseInterface;
|
||||
|
|
135
core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
Normal file
135
core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A Route Provider front-end for all Drupal-stored routes.
|
||||
*/
|
||||
class RouteProviderLazyBuilder implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
|
||||
|
||||
/**
|
||||
* The route provider service.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteProviderInterface
|
||||
*/
|
||||
protected $routeProvider;
|
||||
|
||||
/**
|
||||
* The route building service.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteBuilderInterface
|
||||
*/
|
||||
protected $routeBuilder;
|
||||
|
||||
/**
|
||||
* Flag to determine if the router has been rebuilt.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $rebuilt = FALSE;
|
||||
|
||||
/**
|
||||
* RouteProviderLazyBuilder constructor.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
|
||||
* The route provider service.
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* The route building service.
|
||||
*/
|
||||
public function __construct(RouteProviderInterface $route_provider, RouteBuilderInterface $route_builder) {
|
||||
$this->routeProvider = $route_provider;
|
||||
$this->routeBuilder = $route_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real route provider service and rebuilds the router id necessary.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\RouteProviderInterface
|
||||
* The route provider service.
|
||||
*/
|
||||
protected function getRouteProvider() {
|
||||
if (!$this->rebuilt) {
|
||||
$this->routeBuilder->rebuild();
|
||||
$this->rebuilt = TRUE;
|
||||
}
|
||||
return $this->routeProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteCollectionForRequest(Request $request) {
|
||||
return $this->getRouteProvider()->getRouteCollectionForRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteByName($name) {
|
||||
return $this->getRouteProvider()->getRouteByName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preLoadRoutes($names) {
|
||||
return $this->getRouteProvider()->preLoadRoutes($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByNames($names) {
|
||||
return $this->getRouteProvider()->getRoutesByNames($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByPattern($pattern) {
|
||||
return $this->getRouteProvider()->getRoutesByPattern($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllRoutes() {
|
||||
return $this->getRouteProvider()->getAllRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset() {
|
||||
// Don't call getRouteProvider as this is results in recursive rebuilds.
|
||||
return $this->routeProvider->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesPaged($offset, $length = NULL) {
|
||||
return $this->getRouteProvider()->getRoutesPaged($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesCount() {
|
||||
return $this->getRouteProvider()->getRoutesCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the router has been rebuilt.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE is the router has been rebuilt, FALSE if not.
|
||||
*/
|
||||
public function hasRebuilt() {
|
||||
return $this->rebuilt;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RouteSubscriberBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\RoutingEvents.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\StackedRouteMatchInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\TrustedRedirectResponse.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\UrlGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\GeneratedUrl;
|
||||
|
@ -250,10 +245,10 @@ class UrlGenerator implements UrlGeneratorInterface {
|
|||
* @param $name
|
||||
* The route name or other debug message.
|
||||
* @param \Symfony\Component\Routing\Route $route
|
||||
* The route object.
|
||||
* The route object.
|
||||
* @param array $parameters
|
||||
* An array of parameters as passed to
|
||||
* \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate().
|
||||
* An array of parameters as passed to
|
||||
* \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate().
|
||||
* @param array $query_params
|
||||
* An array of query string parameter, which will get any extra values from
|
||||
* $parameters merged in.
|
||||
|
@ -272,8 +267,8 @@ class UrlGenerator implements UrlGeneratorInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $absolute = FALSE) {
|
||||
$options['absolute'] = $absolute;
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
|
||||
$options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL;
|
||||
return $this->generateFromRoute($name, $parameters, $options);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\UrlGeneratorInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\VersatileGeneratorInterface;
|
||||
|
@ -20,10 +15,10 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
|
|||
* Gets the internal path (system path) for a route.
|
||||
*
|
||||
* @param string|\Symfony\Component\Routing\Route $name
|
||||
* The route name or a route object.
|
||||
* The route name or a route object.
|
||||
* @param array $parameters
|
||||
* An array of parameters as passed to
|
||||
* \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate().
|
||||
* An array of parameters as passed to
|
||||
* \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate().
|
||||
*
|
||||
* @return string
|
||||
* The internal Drupal path corresponding to the route.
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\UrlGeneratorTrait.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Url instead.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
@ -19,6 +11,9 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|||
* classes that would implement ContainerInjectionInterface. Services registered
|
||||
* in the Container should not use this trait but inject the appropriate service
|
||||
* directly for easier testing.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Url instead.
|
||||
*/
|
||||
trait UrlGeneratorTrait {
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Routing\UrlMatcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Path\CurrentPathStack;
|
||||
|
|
Reference in a new issue