Playing with serializer
This commit is contained in:
parent
f0c9be7c39
commit
efa3f9bc09
2 changed files with 3 additions and 6 deletions
|
@ -48,10 +48,10 @@ class ScoreControllerProvider implements ControllerProviderInterface
|
||||||
$game = $request->attributes->get('game');
|
$game = $request->attributes->get('game');
|
||||||
|
|
||||||
if(empty($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')
|
->bind('game')
|
||||||
->convert('game', function($game, Request $request) use ($app){ return $app['entity.manager']->getRepository(Models\Game::class)->find($request->attributes->get('gameId'));});
|
->convert('game', function($game, Request $request) use ($app){ return $app['entity.manager']->getRepository(Models\Game::class)->find($request->attributes->get('gameId'));});
|
||||||
|
|
|
@ -42,9 +42,6 @@ $app['users'] = function () use ($eh) {
|
||||||
$app['serializer'] = function () use ($eh) {
|
$app['serializer'] = function () use ($eh) {
|
||||||
return JMS\Serializer\SerializerBuilder::create()->build();
|
return JMS\Serializer\SerializerBuilder::create()->build();
|
||||||
};
|
};
|
||||||
$app['serializer.json'] = function ($data) use ($app) {
|
|
||||||
return $app['serializer']->serialize($data, 'json');
|
|
||||||
};
|
|
||||||
|
|
||||||
$app['security.firewalls'] = array(
|
$app['security.firewalls'] = array(
|
||||||
'login' => [
|
'login' => [
|
||||||
|
|
Loading…
Reference in a new issue