<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ViewSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
// return the subscribed events, their methods and priorities
return [
KernelEvents::VIEW => [
['onKernelView', 0],
],
];
}
public function onKernelView(ViewEvent $event)
{
$response = new Response();
$response->setContent(bencode(
$event->getControllerResult()
));
$event->setResponse($response);
}
}