-
-
Save anboo/f3a4b93feb76a58f8aae8d5d8d6c42e8 to your computer and use it in GitHub Desktop.
Revisions
-
anboo created this gist
Mar 12, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ <?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', ); } }