git commit -m Issue
parent
7725fcf661
commit
0faa5ce3c3
|
@ -98,10 +98,18 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
|
||||
// Attach globally-declared headers to the response object so that Symfony
|
||||
// can send them for us correctly.
|
||||
// @todo remove this once we have removed all _drupal_add_http_header()
|
||||
// calls.
|
||||
// @todo Remove this once drupal_process_attached() no longer calls
|
||||
// _drupal_add_http_header(), which has its own static. Instead,
|
||||
// _drupal_process_attached() should use
|
||||
// \Symfony\Component\HttpFoundation\Response->headers->set(), which is
|
||||
// already documented on the (deprecated) _drupal_process_attached() to
|
||||
// become the final, intended mechanism.
|
||||
$headers = drupal_get_http_header();
|
||||
foreach ($headers as $name => $value) {
|
||||
// Symfony special-cases the 'Status' header.
|
||||
if ($name === 'status') {
|
||||
$response->setStatusCode($value);
|
||||
}
|
||||
$response->headers->set($name, $value, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\views\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Page\HtmlPage;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Core\Routing\RouteSubscriberBase;
|
||||
|
@ -26,7 +25,6 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
|||
* routes are overridden by views. This information is used to determine which
|
||||
* views have to be added by views in the dynamic event.
|
||||
*
|
||||
* Additional to adding routes it also changes the htmlpage response code.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\display\PathPluginBase
|
||||
*/
|
||||
|
@ -85,7 +83,6 @@ class RouteSubscriber extends RouteSubscriberBase {
|
|||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events = parent::getSubscribedEvents();
|
||||
$events[KernelEvents::VIEW][] = array('onHtmlPage', 75);
|
||||
$events[RoutingEvents::FINISHED] = array('routeRebuildFinished');
|
||||
// Ensure to run after the entity resolver subscriber
|
||||
// @see \Drupal\Core\EventSubscriber\EntityRouteAlterSubscriber
|
||||
|
@ -113,23 +110,6 @@ class RouteSubscriber extends RouteSubscriberBase {
|
|||
return $this->viewsDisplayPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proper response code coming from the http status area handler.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
|
||||
* The Event to process.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\area\HTTPStatusCode
|
||||
*/
|
||||
public function onHtmlPage(GetResponseForControllerResultEvent $event) {
|
||||
$page = $event->getControllerResult();
|
||||
if ($page instanceof HtmlPage) {
|
||||
if (($request = $event->getRequest()) && $request->attributes->has('view_id')) {
|
||||
$page->setStatusCode($request->attributes->get('_http_statuscode', 200));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of route objects.
|
||||
*
|
||||
|
|
|
@ -64,8 +64,8 @@ class HTTPStatusCode extends AreaPluginBase {
|
|||
*/
|
||||
function render($empty = FALSE) {
|
||||
if (!$empty || !empty($this->options['empty'])) {
|
||||
$this->view->getResponse()->setStatusCode($this->options['status_code']);
|
||||
$this->view->getRequest()->attributes->set('_http_statuscode', $this->options['status_code']);
|
||||
$build['#attached']['http_header'][] = ['Status', $this->options['status_code']];
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue