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\EventSubscriber\AcceptNegotiation406.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
@ -34,7 +29,7 @@ class AcceptNegotiation406 implements EventSubscriberInterface {
|
|||
// not HTML though we can also assume that the requested format is invalid
|
||||
// so we provide a 406 response.
|
||||
if (is_array($result) && $request->getRequestFormat() !== 'html') {
|
||||
throw new NotAcceptableHttpException('Not acceptable');
|
||||
throw new NotAcceptableHttpException('Not acceptable format: ' . $request->getRequestFormat());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\AjaxResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\AnonymousUserResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\AuthenticationSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Authentication\AuthenticationProviderFilterInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\CacheRouterRebuildSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ClientErrorResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ConfigImportSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Config\Config;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Config\ConfigEvents;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Access\AccessManagerInterface;
|
||||
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Path\AliasManagerInterface;
|
||||
use Drupal\Core\Routing\AccessAwareRouterInterface;
|
||||
use Drupal\Core\Routing\RedirectDestinationInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||
|
||||
/**
|
||||
* Exception subscriber for handling core custom HTML error pages.
|
||||
|
@ -28,30 +27,32 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
|
|||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* The page alias manager.
|
||||
* The access manager.
|
||||
*
|
||||
* @var \Drupal\Core\Path\AliasManagerInterface
|
||||
* @var \Drupal\Core\Access\AccessManagerInterface
|
||||
*/
|
||||
protected $aliasManager;
|
||||
protected $accessManager;
|
||||
|
||||
/**
|
||||
* Constructs a new CustomPageExceptionHtmlSubscriber.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The configuration factory.
|
||||
* @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
|
||||
* The alias manager service.
|
||||
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
|
||||
* The HTTP Kernel service.
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* The logger service.
|
||||
* @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
|
||||
* The redirect destination service.
|
||||
* @param \Symfony\Component\Routing\Matcher\UrlMatcherInterface $access_unaware_router
|
||||
* A router implementation which does not check access.
|
||||
* @param \Drupal\Core\Access\AccessManagerInterface $access_manager
|
||||
* The access manager.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, AliasManagerInterface $alias_manager, HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination) {
|
||||
parent::__construct($http_kernel, $logger, $redirect_destination);
|
||||
public function __construct(ConfigFactoryInterface $config_factory, HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination, UrlMatcherInterface $access_unaware_router, AccessManagerInterface $access_manager) {
|
||||
parent::__construct($http_kernel, $logger, $redirect_destination, $access_unaware_router);
|
||||
$this->configFactory = $config_factory;
|
||||
$this->aliasManager = $alias_manager;
|
||||
$this->accessManager = $access_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,16 +66,57 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function on403(GetResponseForExceptionEvent $event) {
|
||||
$path = $this->aliasManager->getPathByAlias($this->configFactory->get('system.site')->get('page.403'));
|
||||
$this->makeSubrequest($event, trim($path, '/'), Response::HTTP_FORBIDDEN);
|
||||
$custom_403_path = $this->configFactory->get('system.site')->get('page.403');
|
||||
if (!empty($custom_403_path)) {
|
||||
$this->makeSubrequestToCustomPath($event, $custom_403_path, Response::HTTP_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function on404(GetResponseForExceptionEvent $event) {
|
||||
$path = $this->aliasManager->getPathByAlias($this->configFactory->get('system.site')->get('page.404'));
|
||||
$this->makeSubrequest($event, trim($path, '/'), Response::HTTP_NOT_FOUND);
|
||||
$custom_404_path = $this->configFactory->get('system.site')->get('page.404');
|
||||
if (!empty($custom_404_path)) {
|
||||
$this->makeSubrequestToCustomPath($event, $custom_404_path, Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a subrequest to retrieve the custom error page.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
|
||||
* The event to process.
|
||||
* @param string $custom_path
|
||||
* The custom path to which to make a subrequest for this error message.
|
||||
* @param int $status_code
|
||||
* The status code for the error being handled.
|
||||
*/
|
||||
protected function makeSubrequestToCustomPath(GetResponseForExceptionEvent $event, $custom_path, $status_code) {
|
||||
$url = Url::fromUserInput($custom_path);
|
||||
if ($url->isRouted()) {
|
||||
$access_result = $this->accessManager->checkNamedRoute($url->getRouteName(), $url->getRouteParameters(), NULL, TRUE);
|
||||
$request = $event->getRequest();
|
||||
|
||||
// Merge the custom path's route's access result's cacheability metadata
|
||||
// with the existing one (from the master request), otherwise create it.
|
||||
if (!$request->attributes->has(AccessAwareRouterInterface::ACCESS_RESULT)) {
|
||||
$request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, $access_result);
|
||||
}
|
||||
else {
|
||||
$existing_access_result = $request->attributes->get(AccessAwareRouterInterface::ACCESS_RESULT);
|
||||
if ($existing_access_result instanceof RefinableCacheableDependencyInterface) {
|
||||
$existing_access_result->addCacheableDependency($access_result);
|
||||
}
|
||||
}
|
||||
|
||||
// Only perform the subrequest if the custom path is actually accessible.
|
||||
if (!$access_result->isAllowed()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->makeSubrequest($event, $custom_path, $status_code);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\AccessAwareRouterInterface;
|
||||
use Drupal\Core\Routing\RedirectDestinationInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||
|
||||
/**
|
||||
* Exception subscriber for handling core default HTML error pages.
|
||||
|
@ -44,6 +37,13 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
*/
|
||||
protected $redirectDestination;
|
||||
|
||||
/**
|
||||
* A router implementation which does not check access.
|
||||
*
|
||||
* @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface
|
||||
*/
|
||||
protected $accessUnawareRouter;
|
||||
|
||||
/**
|
||||
* Constructs a new DefaultExceptionHtmlSubscriber.
|
||||
*
|
||||
|
@ -53,11 +53,14 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
* The logger service.
|
||||
* @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
|
||||
* The redirect destination service.
|
||||
* @param \Symfony\Component\Routing\Matcher\UrlMatcherInterface $access_unaware_router
|
||||
* A router implementation which does not check access.
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination) {
|
||||
public function __construct(HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination, UrlMatcherInterface $access_unaware_router) {
|
||||
$this->httpKernel = $http_kernel;
|
||||
$this->logger = $logger;
|
||||
$this->redirectDestination = $redirect_destination;
|
||||
$this->accessUnawareRouter = $access_unaware_router;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +86,7 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
* The event to process.
|
||||
*/
|
||||
public function on401(GetResponseForExceptionEvent $event) {
|
||||
$this->makeSubrequest($event, Url::fromRoute('system.401')->toString(), Response::HTTP_UNAUTHORIZED);
|
||||
$this->makeSubrequest($event, '/system/401', Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +96,7 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
* The event to process.
|
||||
*/
|
||||
public function on403(GetResponseForExceptionEvent $event) {
|
||||
$this->makeSubrequest($event, Url::fromRoute('system.403')->toString(), Response::HTTP_FORBIDDEN);
|
||||
$this->makeSubrequest($event, '/system/403', Response::HTTP_FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,14 +106,14 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
* The event to process.
|
||||
*/
|
||||
public function on404(GetResponseForExceptionEvent $event) {
|
||||
$this->makeSubrequest($event, Url::fromRoute('system.404')->toString(), Response::HTTP_NOT_FOUND);
|
||||
$this->makeSubrequest($event, '/system/404', Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a subrequest to retrieve the default error page.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
|
||||
* The event to process
|
||||
* The event to process.
|
||||
* @param string $url
|
||||
* The path/url to which to make a subrequest for this error message.
|
||||
* @param int $status_code
|
||||
|
@ -120,54 +123,46 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
$request = $event->getRequest();
|
||||
$exception = $event->getException();
|
||||
|
||||
if (!($url && $url[0] == '/')) {
|
||||
$url = $request->getBasePath() . '/' . $url;
|
||||
try {
|
||||
// Reuse the exact same request (so keep the same URL, keep the access
|
||||
// result, the exception, et cetera) but override the routing information.
|
||||
// This means that aside from routing, this is identical to the master
|
||||
// request. This allows us to generate a response that is executed on
|
||||
// behalf of the master request, i.e. for the original URL. This is what
|
||||
// allows us to e.g. generate a 404 response for the original URL; if we
|
||||
// would execute a subrequest with the 404 route's URL, then it'd be
|
||||
// generated for *that* URL, not the *original* URL.
|
||||
$sub_request = clone $request;
|
||||
$sub_request->attributes->add($this->accessUnawareRouter->match($url));
|
||||
|
||||
// Add to query (GET) or request (POST) parameters:
|
||||
// - 'destination' (to ensure e.g. the login form in a 403 response
|
||||
// redirects to the original URL)
|
||||
// - '_exception_statuscode'
|
||||
$parameters = $sub_request->isMethod('GET') ? $sub_request->query : $sub_request->request;
|
||||
$parameters->add($this->redirectDestination->getAsArray() + ['_exception_statuscode' => $status_code]);
|
||||
|
||||
$response = $this->httpKernel->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
|
||||
// Only 2xx responses should have their status code overridden; any
|
||||
// other status code should be passed on: redirects (3xx), error (5xx)…
|
||||
// @see https://www.drupal.org/node/2603788#comment-10504916
|
||||
if ($response->isSuccessful()) {
|
||||
$response->setStatusCode($status_code);
|
||||
}
|
||||
|
||||
// Persist any special HTTP headers that were set on the exception.
|
||||
if ($exception instanceof HttpExceptionInterface) {
|
||||
$response->headers->add($exception->getHeaders());
|
||||
}
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
$current_url = $request->getBasePath() . $request->getPathInfo();
|
||||
|
||||
if ($url != $request->getBasePath() . '/' && $url != $current_url) {
|
||||
if ($request->getMethod() === 'POST') {
|
||||
$sub_request = Request::create($url, 'POST', $this->redirectDestination->getAsArray() + ['_exception_statuscode' => $status_code] + $request->request->all(), $request->cookies->all(), [], $request->server->all());
|
||||
}
|
||||
else {
|
||||
$sub_request = Request::create($url, 'GET', $request->query->all() + $this->redirectDestination->getAsArray() + ['_exception_statuscode' => $status_code], $request->cookies->all(), [], $request->server->all());
|
||||
}
|
||||
|
||||
try {
|
||||
// Persist the 'exception' attribute to the subrequest.
|
||||
$sub_request->attributes->set('exception', $request->attributes->get('exception'));
|
||||
// Persist the access result attribute to the subrequest, so that the
|
||||
// error page inherits the access result of the master request.
|
||||
$sub_request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, $request->attributes->get(AccessAwareRouterInterface::ACCESS_RESULT));
|
||||
|
||||
// Carry over the session to the subrequest.
|
||||
if ($session = $request->getSession()) {
|
||||
$sub_request->setSession($session);
|
||||
}
|
||||
|
||||
$response = $this->httpKernel->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
|
||||
// Only 2xx responses should have their status code overridden; any
|
||||
// other status code should be passed on: redirects (3xx), error (5xx)…
|
||||
// @see https://www.drupal.org/node/2603788#comment-10504916
|
||||
if ($response->isSuccessful()) {
|
||||
$response->setStatusCode($status_code);
|
||||
}
|
||||
|
||||
// Persist any special HTTP headers that were set on the exception.
|
||||
if ($exception instanceof HttpExceptionInterface) {
|
||||
$response->headers->add($exception->getHeaders());
|
||||
}
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// If an error happened in the subrequest we can't do much else. Instead,
|
||||
// just log it. The DefaultExceptionSubscriber will catch the original
|
||||
// exception and handle it normally.
|
||||
$error = Error::decodeException($e);
|
||||
$this->logger->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// If an error happened in the subrequest we can't do much else. Instead,
|
||||
// just log it. The DefaultExceptionSubscriber will catch the original
|
||||
// exception and handle it normally.
|
||||
$error = Error::decodeException($e);
|
||||
$this->logger->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\DefaultExceptionSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
@ -165,6 +160,20 @@ class DefaultExceptionSubscriber implements EventSubscriberInterface {
|
|||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an HttpExceptionInterface exception for unknown formats.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
|
||||
* The event to process.
|
||||
*/
|
||||
protected function onFormatUnknown(GetResponseForExceptionEvent $event) {
|
||||
/** @var \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface|\Exception $exception */
|
||||
$exception = $event->getException();
|
||||
|
||||
$response = new Response($exception->getMessage(), $exception->getStatusCode(), $exception->getHeaders());
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles errors for this subscriber.
|
||||
*
|
||||
|
@ -173,11 +182,17 @@ class DefaultExceptionSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public function onException(GetResponseForExceptionEvent $event) {
|
||||
$format = $this->getFormat($event->getRequest());
|
||||
$exception = $event->getException();
|
||||
|
||||
// If it's an unrecognized format, assume HTML.
|
||||
$method = 'on' . $format;
|
||||
if (!method_exists($this, $method)) {
|
||||
$method = 'onHtml';
|
||||
if ($exception instanceof HttpExceptionInterface) {
|
||||
$this->onFormatUnknown($event);
|
||||
}
|
||||
else {
|
||||
$this->onHtml($event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->$method($event);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Form\EnforcedResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\EntityRouteAlterSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Entity\EntityResolverManager;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\EntityRouteProviderSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ExceptionTestSiteSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Utility\Error;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\Fast404ExceptionHtmlSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\FinishResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Datetime\DateTimePlus;
|
||||
|
@ -263,7 +258,7 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
* A response object.
|
||||
*/
|
||||
protected function setCacheControlNoCache(Response $response) {
|
||||
$response->headers->set('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
|
||||
$response->headers->set('Cache-Control', 'no-cache, must-revalidate');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\HtmlResponsePlaceholderStrategySubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Render\HtmlResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\HtmlResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Render\HtmlResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\KernelDestructionSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\MainContentViewSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ModuleRouteSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteProviderInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Handles options requests.
|
||||
*
|
||||
* Therefore it sends a options response using all methods on all possible
|
||||
* routes.
|
||||
*/
|
||||
class OptionsRequestSubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The route provider.
|
||||
*
|
||||
* @var \Symfony\Cmf\Component\Routing\RouteProviderInterface
|
||||
*/
|
||||
protected $routeProvider;
|
||||
|
||||
/**
|
||||
* Creates a new OptionsRequestSubscriber instance.
|
||||
*
|
||||
* @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider
|
||||
* The route provider.
|
||||
*/
|
||||
public function __construct(RouteProviderInterface $route_provider) {
|
||||
$this->routeProvider = $route_provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to handle the options request.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
|
||||
* The request event.
|
||||
*/
|
||||
public function onRequest(GetResponseEvent $event) {
|
||||
if ($event->getRequest()->isMethod('OPTIONS')) {
|
||||
$routes = $this->routeProvider->getRouteCollectionForRequest($event->getRequest());
|
||||
// In case we don't have any routes, a 403 should be thrown by the normal
|
||||
// request handling.
|
||||
if (count($routes) > 0) {
|
||||
$methods = array_map(function (Route $route) {
|
||||
return $route->getMethods();
|
||||
}, $routes->all());
|
||||
// Flatten and unique the available methods.
|
||||
$methods = array_unique(call_user_func_array('array_merge', $methods));
|
||||
$response = new Response('', 200, ['Allow' => implode(', ', $methods)]);
|
||||
$event->setResponse($response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
// Set a high priority so it is executed before routing.
|
||||
$events[KernelEvents::REQUEST][] = ['onRequest', 1000];
|
||||
return $events;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ParamConverterSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\ParamConverter\ParamConverterManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\PathRootsSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\State\StateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\PathSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Path\AliasManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\PsrResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RedirectLeadingSlashesSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheableRedirectResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RedirectResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\HttpFoundation\SecuredRedirectResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ReplicaDatabaseIgnoreSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RequestCloseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\ResponseGeneratorSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RouteAccessResponseSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheableResponseInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RouteEnhancerSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\LazyRouteEnhancer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RouteFilterSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\LazyRouteFilter;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RouteMethodSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\RouteBuildEvent;
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\RouterRebuildSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\RouteBuilderInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* Rebuilds the router if needed at the end of the request.
|
||||
*/
|
||||
class RouterRebuildSubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Routing\RouteBuilderInterface
|
||||
*/
|
||||
protected $routeBuilder;
|
||||
|
||||
/**
|
||||
* Constructs the RouterRebuildSubscriber object.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* The route builder.
|
||||
*/
|
||||
public function __construct(RouteBuilderInterface $route_builder) {
|
||||
$this->routeBuilder = $route_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds routers if necessary.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
|
||||
* The event object.
|
||||
*/
|
||||
public function onKernelTerminate(PostResponseEvent $event) {
|
||||
$this->routeBuilder->rebuildIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
static function getSubscribedEvents() {
|
||||
$events[KernelEvents::TERMINATE][] = array('onKernelTerminate', 200);
|
||||
return $events;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Routing\RouteBuildEvent;
|
||||
|
|
Reference in a new issue