Skip to content

Commit

Permalink
ServiceController returns Response for scalar result and JsonResponse…
Browse files Browse the repository at this point in the history
… for other
  • Loading branch information
Cosmologist committed Nov 2, 2018
1 parent 58db17d commit 6437b4d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Controller/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\Bundle\DoctrineBundle\Registry;
use ReflectionMethod;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
Expand Down Expand Up @@ -52,7 +53,7 @@ public function __construct(ContainerInterface $container, Registry $registry)
* @param string $service Service identifier
* @param string $method Service method
*
* @return Response
* @return Response|JsonResponse Simple response for scalar results and JSON for other
*/
public function callServiceAction(Request $request, string $service, string $method): Response
{
Expand Down Expand Up @@ -97,8 +98,6 @@ public function callServiceAction(Request $request, string $service, string $met
return new Response($result);
}

// todo: implement result analyzing and return it in the suitable format

return new Response();
return new JsonResponse($result);
}
}

0 comments on commit 6437b4d

Please sign in to comment.