-
-
Save anboo/f3a4b93feb76a58f8aae8d5d8d6c42e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\EventListener\Core; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; | |
use Symfony\Component\HttpKernel\KernelEvents; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
use JMS\DiExtraBundle\Annotation as DI; | |
class ApiAnnotationControllerListener implements EventSubscriberInterface | |
{ | |
public function onGetResponseForController(GetResponseForControllerResultEvent $event) | |
{ | |
$array = $event->getControllerResult(); | |
$convertedArray = $this->convert($array); | |
$event->setResponse(new JsonResponse($convertedArray)); | |
} | |
public static function getSubscribedEvents() | |
{ | |
return array( | |
KernelEvents::VIEW => 'onGetResponseForController', | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment