Test game

This commit is contained in:
Ruben 2016-09-04 11:54:48 +01:00
parent a7f0415eb4
commit 2ded8129b1
2 changed files with 17 additions and 2 deletions

View File

@ -43,10 +43,20 @@ class ScoreControllerProvider implements ControllerProviderInterface
return $app['serializer']->serialize($user, 'json');
});
$controllers->get('/games/{gameId}', function(Request $request, Application $app) {
$game = $request->attributes->get('game');
return $app['serializer']->serialize($game, 'json');
})
->bind('game')
->convert('game', function($game, Request $request) use ($app){ return $app['entity.manager']->getRepository(Models\Game::class)->find($request->attributes->get('gameId'));});
/**
* Expects a full game + hits in the request
*/
$controllers->post('/me/games', function (Request $request, Application $app) {
$controllers->post('/games', function (Request $request, Application $app) {
$data = json_decode($request->getContent(), true);
$token = $app['security.token_storage']->getToken();
$user = $token->getUser();
@ -99,7 +109,7 @@ class ScoreControllerProvider implements ControllerProviderInterface
$hit->setPoint($i, $data_hit['points']["$i"]['x'], $data_hit['points']["$i"]['y']);
}
// set game appends hit to game
$hit->setGame($game);

View File

@ -19,6 +19,11 @@ $app = new Silex\Application([
define('USER_ID_FIELD', 'id');
$app['entity.manager'] = function() {
return EmotionHero\Application::getInstance()->getEm();
};
$app['security.jwt'] = [
'secret_key' => $eh->getConfig()['secret_key'],