Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Core\Access\AccessManagerInterface;
|
||||
use Drupal\Core\Access\AccessResultReasonInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Symfony\Cmf\Component\Routing\ChainRouter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -105,7 +106,7 @@ class AccessAwareRouter implements AccessAwareRouterInterface {
|
|||
$request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, $access_result);
|
||||
}
|
||||
if (!$access_result->isAllowed()) {
|
||||
throw new AccessDeniedHttpException();
|
||||
throw new AccessDeniedHttpException($access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
57
core/lib/Drupal/Core/Routing/MethodFilter.php
Normal file
57
core/lib/Drupal/Core/Routing/MethodFilter.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* Filters routes based on the HTTP method.
|
||||
*/
|
||||
class MethodFilter implements RouteFilterInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function filter(RouteCollection $collection, Request $request) {
|
||||
$method = $request->getMethod();
|
||||
|
||||
$all_supported_methods = [];
|
||||
|
||||
foreach ($collection->all() as $name => $route) {
|
||||
$supported_methods = $route->getMethods();
|
||||
|
||||
// A route not restricted to specific methods allows any method. If this
|
||||
// is the case, we'll also have at least one route left in the collection,
|
||||
// hence we don't need to calculate the set of all supported methods.
|
||||
if (empty($supported_methods)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the GET method is allowed we also need to allow the HEAD method
|
||||
// since HEAD is a GET method that doesn't return the body.
|
||||
if (in_array('GET', $supported_methods, TRUE)) {
|
||||
$supported_methods[] = 'HEAD';
|
||||
}
|
||||
|
||||
if (!in_array($method, $supported_methods, TRUE)) {
|
||||
$all_supported_methods = array_merge($supported_methods, $all_supported_methods);
|
||||
$collection->remove($name);
|
||||
}
|
||||
}
|
||||
if (count($collection)) {
|
||||
return $collection;
|
||||
}
|
||||
throw new MethodNotAllowedException(array_unique($all_supported_methods));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies(Route $route) {
|
||||
return !empty($route->getMethods());
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\Core\Routing;
|
||||
|
||||
use Drupal\Component\Discovery\YamlDiscovery;
|
||||
use Drupal\Core\Access\CheckProviderInterface;
|
||||
use Drupal\Core\Controller\ControllerResolverInterface;
|
||||
use Drupal\Core\Discovery\YamlDiscovery;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Lock\LockBackendInterface;
|
||||
use Drupal\Core\DestructableInterface;
|
||||
|
|
|
@ -28,7 +28,7 @@ interface StackedRouteMatchInterface extends RouteMatchInterface {
|
|||
/**
|
||||
* Returns the parent route match of the current.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface|NULL
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface|null
|
||||
* The parent route match or NULL, if it the master route match.
|
||||
*/
|
||||
public function getParentRouteMatch();
|
||||
|
@ -36,10 +36,10 @@ interface StackedRouteMatchInterface extends RouteMatchInterface {
|
|||
/**
|
||||
* Returns a route match from a given request, if possible.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* The request.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface|NULL
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface|null
|
||||
* THe matching route match, or NULL if there is no matching one.
|
||||
*/
|
||||
public function getRouteMatchFromRequest(Request $request);
|
||||
|
|
Reference in a new issue