_eh = EH::getInstance(); } public function connect(Application $app) { // creates a new controller based on the default route $controllers = $app['controllers_factory']; $controllers->get('/', function (Application $app) { return "OK"; }); $controllers->get('/levels', function (Application $app) { $levels = $this->_eh->getEm()->getRepository(Models\Level::class)->findAll(); return $app['serializer']->serialize($levels, 'json'); }); $controllers->get('/emotions', function (Application $app) { $levels = $this->_eh->getEm()->getRepository(Models\Emotion::class)->findAll(); return $app['serializer']->serialize($levels, 'json'); }); $controllers->get('/me', function (Application $app) { $token = $app['security.token_storage']->getToken(); $user = $token->getUser(); return $app['serializer']->serialize($user, 'json'); }); $controllers->post('/me/games', function (Request $request, Application $app) { $vars = json_decode($request->getContent(), true); var_dump($vars); return $app['serializer']->serialize($levels, 'json'); }); return $controllers; } }