Use a HttpKernel event to translate to a request

We return render arrays from requests ATM and until we transition to actual
request objects, we need to translate so Symfony can function.
8.0.x
James Gilliland 2012-02-13 16:02:34 -05:00
parent cf096e698a
commit 55a8203bdb
1 changed files with 7 additions and 1 deletions

View File

@ -4,10 +4,11 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;
use Symfony\Component\HttpKernel;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Drupal\Core\UrlMatcher;
/**
* Execute the page callback associated with given request.
*
@ -33,6 +34,11 @@ function router_execute_request(Request $request) {
$arguments = $resolver->getArguments($request, $controller);
$dispatcher = new EventDispatcher();
// Quick and dirty attempt at wrapping our rendering logic as is.
$dispatcher->addListener(KernelEvents::VIEW, function(Event $event) {
$page_callback_result = $event->getControllerResult();
$event->setResponse(new Response(drupal_render_page($page_callback_result)));
});
$kernel = new HttpKernel\HttpKernel($dispatcher, $resolver);
return $kernel->handle($request);