Skip to content
Permalink
Browse files

Use sf-provided listener instead of rolling our own

  • Loading branch information
flack committed Nov 20, 2019
1 parent ab8c9b5 commit ba39fbcffb5a007e0c008c65693fbfb7d72b1c5b
Showing with 2 additions and 16 deletions.
  1. +2 −0 lib/midcom.php
  2. +0 −16 src/midcom/httpkernel/subscriber.php
@@ -12,6 +12,7 @@
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpFoundation\RequestStack;
use midcom\httpkernel\subscriber;
use Symfony\Component\HttpKernel\EventListener\StreamedResponseListener;
/**
* @package midcom
@@ -96,6 +97,7 @@ public static function init() : HttpKernel
self::$_services['dispatcher'] = new dispatcher;
self::$_services['dispatcher']->addSubscriber(new subscriber);
self::$_services['dispatcher']->addSubscriber(new StreamedResponseListener);
$c_resolver = new ControllerResolver;
$a_resolver = new ArgumentResolver;
$kernel = new HttpKernel(self::$_services['dispatcher'], $c_resolver, new RequestStack, $a_resolver);
@@ -21,8 +21,6 @@
use midcom_connection;
use midcom_core_context;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* @package midcom.httpkernel
@@ -37,7 +35,6 @@ public static function getSubscribedEvents()
KernelEvents::REQUEST => ['on_request'],
KernelEvents::CONTROLLER_ARGUMENTS => ['on_arguments'],
KernelEvents::VIEW => ['on_view'],
KernelEvents::RESPONSE => ['on_response'],
KernelEvents::EXCEPTION => ['on_exception']
];
}
@@ -111,19 +108,6 @@ public function on_view(GetResponseForControllerResultEvent $event)
$event->setResponse(new midcom_response_styled($attributes->get('context')));
}
public function on_response(FilterResponseEvent $event)
{
if ($event->isMasterRequest()) {
$response = $event->getResponse();
if ($response instanceof StreamedResponse) {
// if we have a streamed response, we need to send right away
// otherwise exceptions in the callback won't be caught by the kernel
// which means e.g. that a midcom-exec script couldn't show a login screen
$response->send();
}
}
}
public function on_exception(GetResponseForExceptionEvent $event)
{
$handler = new \midcom_exception_handler();

0 comments on commit ba39fbc

Please sign in to comment.
You can’t perform that action at this time.