From efa3f9bc09a55f1cbc8b10abdc84b8057ca6d2c7 Mon Sep 17 00:00:00 2001 From: Ruben Date: Sun, 4 Sep 2016 13:01:30 +0100 Subject: [PATCH] Playing with serializer --- src/Api/ScoreControllerProvider.php | 6 +++--- www/index.php | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Api/ScoreControllerProvider.php b/src/Api/ScoreControllerProvider.php index 144dd7b..b691ace 100644 --- a/src/Api/ScoreControllerProvider.php +++ b/src/Api/ScoreControllerProvider.php @@ -48,10 +48,10 @@ class ScoreControllerProvider implements ControllerProviderInterface $game = $request->attributes->get('game'); if(empty($game)) { - return new CustomJsonResponse(['message' => 'Game not found'], $app['serializer.json'], 404); + return new CustomJsonResponse(['message' => 'Game not found'], function($data) use ($app){return $app['serializer']->serialize($data, 'json');}, 404); } - - return new CustomJsonResponse($game, $app['serializer.json']); + + return new CustomJsonResponse($game, function($data) use ($app){return $app['serializer']->serialize($data, 'json');}, 200); }) ->bind('game') ->convert('game', function($game, Request $request) use ($app){ return $app['entity.manager']->getRepository(Models\Game::class)->find($request->attributes->get('gameId'));}); diff --git a/www/index.php b/www/index.php index b9fb59d..c4274c2 100644 --- a/www/index.php +++ b/www/index.php @@ -42,9 +42,6 @@ $app['users'] = function () use ($eh) { $app['serializer'] = function () use ($eh) { return JMS\Serializer\SerializerBuilder::create()->build(); }; -$app['serializer.json'] = function ($data) use ($app) { - return $app['serializer']->serialize($data, 'json'); -}; $app['security.firewalls'] = array( 'login' => [