diff --git a/src/Api/ScoreControllerProvider.php b/src/Api/ScoreControllerProvider.php index b691ace..df630dd 100644 --- a/src/Api/ScoreControllerProvider.php +++ b/src/Api/ScoreControllerProvider.php @@ -51,7 +51,7 @@ class ScoreControllerProvider implements ControllerProviderInterface return new CustomJsonResponse(['message' => 'Game not found'], function($data) use ($app){return $app['serializer']->serialize($data, 'json');}, 404); } - return new CustomJsonResponse($game, function($data) use ($app){return $app['serializer']->serialize($data, 'json');}, 200); + return new CustomJsonResponse($game, $app['serializer.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 c4274c2..3d0df38 100644 --- a/www/index.php +++ b/www/index.php @@ -42,6 +42,11 @@ $app['users'] = function () use ($eh) { $app['serializer'] = function () use ($eh) { return JMS\Serializer\SerializerBuilder::create()->build(); }; +$app['serializer.json'] = function () use ($app) { + return function($data) use ($app) { + return $app['serializer']->serialize($data, 'json'); + }; +}; $app['security.firewalls'] = array( 'login' => [