Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -134,12 +134,17 @@ class ActiveLinkResponseFilter implements EventSubscriberInterface {
|
|||
$search_key_current_path = 'data-drupal-link-system-path="' . $current_path . '"';
|
||||
$search_key_front = 'data-drupal-link-system-path="<front>"';
|
||||
|
||||
// An active link's path is equal to the current path, so search the HTML
|
||||
// for an attribute with that value.
|
||||
$offset = 0;
|
||||
// There are two distinct conditions that can make a link be marked active:
|
||||
// 1. A link has the current path in its 'data-drupal-link-system-path'
|
||||
// attribute.
|
||||
// 2. We are on the front page and a link has the special '<front>' value in
|
||||
// its 'data-drupal-link-system-path' attribute.
|
||||
while (strpos($html_markup, $search_key_current_path, $offset) !== FALSE || ($is_front && strpos($html_markup, $search_key_front, $offset) !== FALSE)) {
|
||||
$pos_current_path = strpos($html_markup, $search_key_current_path, $offset);
|
||||
$pos_front = strpos($html_markup, $search_key_front, $offset);
|
||||
// Only look for links with the special '<front>' system path if we are
|
||||
// actually on the front page.
|
||||
$pos_front = $is_front ? strpos($html_markup, $search_key_front, $offset) : FALSE;
|
||||
|
||||
// Determine which of the two values is the next match: the exact path, or
|
||||
// the <front> special case.
|
||||
|
|
|
@ -40,7 +40,7 @@ class ContentControllerSubscriber implements EventSubscriberInterface {
|
|||
* An array of event listener definitions.
|
||||
*/
|
||||
static function getSubscribedEvents() {
|
||||
$events[KernelEvents::REQUEST][] = array('onRequestDeriveFormWrapper', 29);
|
||||
$events[KernelEvents::REQUEST][] = array('onRequestDeriveFormWrapper', 25);
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
@ -45,7 +44,7 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public function on403(GetResponseForExceptionEvent $event) {
|
||||
$request = $event->getRequest();
|
||||
$this->logger->get('access denied')->warning(SafeMarkup::checkPlain($request->getRequestUri()));
|
||||
$this->logger->get('access denied')->warning('@uri', ['@uri' => $request->getRequestUri()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +55,7 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public function on404(GetResponseForExceptionEvent $event) {
|
||||
$request = $event->getRequest();
|
||||
$this->logger->get('page not found')->warning(SafeMarkup::checkPlain($request->getRequestUri()));
|
||||
$this->logger->get('page not found')->warning('@uri', ['@uri' => $request->getRequestUri()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,13 +115,30 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
$response->headers->set('X-Content-Type-Options', 'nosniff', FALSE);
|
||||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', FALSE);
|
||||
|
||||
// If the current response isn't an implementation of the
|
||||
// CacheableResponseInterface, we assume that a Response is either
|
||||
// explicitly not cacheable or that caching headers are already set in
|
||||
// another place.
|
||||
if (!$response instanceof CacheableResponseInterface) {
|
||||
if (!$this->isCacheControlCustomized($response)) {
|
||||
$this->setResponseNotCacheable($response, $request);
|
||||
}
|
||||
|
||||
// HTTP/1.0 proxies do not support the Vary header, so prevent any caching
|
||||
// by sending an Expires date in the past. HTTP/1.1 clients ignore the
|
||||
// Expires header if a Cache-Control: max-age directive is specified (see
|
||||
// RFC 2616, section 14.9.3).
|
||||
if (!$response->headers->has('Expires')) {
|
||||
$this->setExpiresNoCache($response);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Expose the cache contexts and cache tags associated with this page in a
|
||||
// X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively.
|
||||
if ($response instanceof CacheableResponseInterface) {
|
||||
$response_cacheability = $response->getCacheableMetadata();
|
||||
$response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
|
||||
$response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
|
||||
}
|
||||
$response_cacheability = $response->getCacheableMetadata();
|
||||
$response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
|
||||
$response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
|
||||
|
||||
$is_cacheable = ($this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) && ($this->responsePolicy->check($response, $request) !== ResponsePolicyInterface::DENY);
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\EventSubscriber\HtmlResponsePlaceholderStrategySubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Render\HtmlResponse;
|
||||
use Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* HTML response subscriber to allow for different placeholder strategies.
|
||||
*
|
||||
* This allows core and contrib to coordinate how to render placeholders;
|
||||
* e.g. an EsiRenderStrategy could replace the placeholders with ESI tags,
|
||||
* while e.g. a BigPipeRenderStrategy could store the placeholders in a
|
||||
* BigPipe service and render them after the main content has been sent to
|
||||
* the client.
|
||||
*/
|
||||
class HtmlResponsePlaceholderStrategySubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The placeholder strategy to use.
|
||||
*
|
||||
* @var \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface
|
||||
*/
|
||||
protected $placeholderStrategy;
|
||||
|
||||
/**
|
||||
* Constructs a HtmlResponsePlaceholderStrategySubscriber object.
|
||||
*
|
||||
* @param \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface $placeholder_strategy
|
||||
* The placeholder strategy to use.
|
||||
*/
|
||||
public function __construct(PlaceholderStrategyInterface $placeholder_strategy) {
|
||||
$this->placeholderStrategy = $placeholder_strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes placeholders for HTML responses.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
|
||||
* The event to process.
|
||||
*/
|
||||
public function onRespond(FilterResponseEvent $event) {
|
||||
if (!$event->isMasterRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = $event->getResponse();
|
||||
if (!$response instanceof HtmlResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attachments = $response->getAttachments();
|
||||
if (empty($attachments['placeholders'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attachments['placeholders'] = $this->placeholderStrategy->processPlaceholders($attachments['placeholders']);
|
||||
|
||||
$response->setAttachments($attachments);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
// Run shortly before HtmlResponseSubscriber.
|
||||
$events[KernelEvents::RESPONSE][] = ['onRespond', 5];
|
||||
return $events;
|
||||
}
|
||||
|
||||
}
|
|
@ -116,7 +116,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
|
|||
// settings page.
|
||||
if ($route_match->getRouteName() != 'system.site_maintenance_mode') {
|
||||
if ($this->account->hasPermission('administer site configuration')) {
|
||||
$this->drupalSetMessage($this->t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => $this->urlGenerator->generate('system.site_maintenance_mode'))), 'status', FALSE);
|
||||
$this->drupalSetMessage($this->t('Operating in maintenance mode. <a href=":url">Go online.</a>', array(':url' => $this->urlGenerator->generate('system.site_maintenance_mode'))), 'status', FALSE);
|
||||
}
|
||||
else {
|
||||
$this->drupalSetMessage($this->t('Operating in maintenance mode.'), 'status', FALSE);
|
||||
|
|
|
@ -11,7 +11,7 @@ use Drupal\Component\HttpFoundation\SecuredRedirectResponse;
|
|||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Routing\LocalRedirectResponse;
|
||||
use Drupal\Core\Routing\RequestContext;
|
||||
use Drupal\Core\Routing\UrlGeneratorInterface;
|
||||
use Drupal\Core\Utility\UnroutedUrlAssemblerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
@ -25,22 +25,22 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
class RedirectResponseSubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The url generator service.
|
||||
* The unrouted URL assembler service.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\UrlGeneratorInterface
|
||||
* @var \Drupal\Core\Utility\UnroutedUrlAssemblerInterface
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
protected $unroutedUrlAssembler;
|
||||
|
||||
/**
|
||||
* Constructs a RedirectResponseSubscriber object.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
|
||||
* The url generator service.
|
||||
* @param \Drupal\Core\Utility\UnroutedUrlAssemblerInterface $url_assembler
|
||||
* The unrouted URL assembler service.
|
||||
* @param \Drupal\Core\Routing\RequestContext $request_context
|
||||
* The request context.
|
||||
*/
|
||||
public function __construct(UrlGeneratorInterface $url_generator, RequestContext $request_context) {
|
||||
$this->urlGenerator = $url_generator;
|
||||
public function __construct(UnroutedUrlAssemblerInterface $url_assembler, RequestContext $request_context) {
|
||||
$this->unroutedUrlAssembler = $url_assembler;
|
||||
$this->requestContext = $request_context;
|
||||
}
|
||||
|
||||
|
@ -117,19 +117,18 @@ class RedirectResponseSubscriber implements EventSubscriberInterface {
|
|||
$destination = $scheme_and_host . $destination;
|
||||
}
|
||||
else {
|
||||
// Legacy destination query parameters can be relative paths that have
|
||||
// not yet been converted to URLs (outbound path processors and other
|
||||
// URL handling still needs to be performed).
|
||||
// @todo As generateFromPath() is deprecated, remove this in
|
||||
// https://www.drupal.org/node/2418219.
|
||||
// Legacy destination query parameters can be internal paths that have
|
||||
// not yet been converted to URLs.
|
||||
$destination = UrlHelper::parse($destination);
|
||||
$path = $destination['path'];
|
||||
$uri = 'base:' . $destination['path'];
|
||||
$options = [
|
||||
'query' => $destination['query'],
|
||||
'fragment' => $destination['fragment'],
|
||||
'absolute' => TRUE,
|
||||
];
|
||||
$destination = $this->urlGenerator->generateFromPath($path, $options);
|
||||
// Treat this as if it's user input of a path relative to the site's
|
||||
// base URL.
|
||||
$destination = $this->unroutedUrlAssembler->assemble($uri, $options);
|
||||
}
|
||||
}
|
||||
return $destination;
|
||||
|
|
Reference in a new issue