Update to Drupal 8.1.5. For more information, see https://www.drupal.org/project/drupal/releases/8.1.5
This commit is contained in:
parent
13b6ca7cc2
commit
38ba7c357d
342 changed files with 7814 additions and 1534 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Render\BareHtmlPageRendererInterface;
|
||||
use Drupal\Core\Routing\RouteMatch;
|
||||
|
@ -13,6 +12,7 @@ use Drupal\Core\Site\MaintenanceModeInterface;
|
|||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
|
@ -90,18 +90,25 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
|
|||
* The event to process.
|
||||
*/
|
||||
public function onKernelRequestMaintenance(GetResponseEvent $event) {
|
||||
$route_match = RouteMatch::createFromRequest($event->getRequest());
|
||||
$request = $event->getRequest();
|
||||
$route_match = RouteMatch::createFromRequest($request);
|
||||
if ($this->maintenanceMode->applies($route_match)) {
|
||||
// Don't cache maintenance mode pages.
|
||||
\Drupal::service('page_cache_kill_switch')->trigger();
|
||||
|
||||
if (!$this->maintenanceMode->exempt($this->account)) {
|
||||
// Deliver the 503 page if the site is in maintenance mode and the
|
||||
// logged in user is not allowed to bypass it.
|
||||
|
||||
// If the request format is not 'html' then show default maintenance
|
||||
// mode page else show a text/plain page with maintenance message.
|
||||
if ($request->getRequestFormat() !== 'html') {
|
||||
$response = new Response($this->getSiteMaintenanceMessage(), 503, array('Content-Type' => 'text/plain'));
|
||||
$event->setResponse($response);
|
||||
return;
|
||||
}
|
||||
drupal_maintenance_theme();
|
||||
$content = Xss::filterAdmin(SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array(
|
||||
'@site' => $this->config->get('system.site')->get('name'),
|
||||
)));
|
||||
$response = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'maintenance_page');
|
||||
$response = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $this->getSiteMaintenanceMessage()], $this->t('Site under maintenance'), 'maintenance_page');
|
||||
$response->setStatusCode(503);
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
@ -121,6 +128,18 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the site maintenance message.
|
||||
*
|
||||
* @return \Drupal\Component\Render\MarkupInterface
|
||||
* The formatted site maintenance message.
|
||||
*/
|
||||
protected function getSiteMaintenanceMessage() {
|
||||
return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array(
|
||||
'@site' => $this->config->get('system.site')->get('name'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the drupal_set_message function.
|
||||
*/
|
||||
|
|
Reference in a new issue