mount('/UserPreferences/', new UserPreferences()); $app->mount('/query/', new Query()); $app->mount('/baskets', new Basket()); $app->mount('/story', new Story()); $app->mount('/WorkZone', new WorkZone()); $app->mount('/lists', new UsrLists()); $app->mount('/MustacheLoader', new MustacheLoader()); $app->mount('/records/edit', new Edit()); $app->mount('/records/movecollection', new MoveCollection()); $app->mount('/bridge/', new Bridge()); $app->mount('/push/', new Push()); $app->mount('/printer/', new Printer()); $app->mount('/TOU/', new TOU()); $app->mount('/feeds', new Feed()); $app->mount('/tooltip', new Tooltip()); $app->mount('/language', new Language()); $app->mount('/tools/', new Tools()); $app->mount('/lazaret/', new Lazaret()); $app->mount('/upload/', new Upload()); $app->mount('/', new Root()); $app->error(function (\Exception $e, $code) use ($app) { /* @var $request \Symfony\Component\HttpFoundation\Request */ $request = $app['request']; if ($request->getRequestFormat() == 'json') { $datas = array( 'success' => false , 'message' => $e->getMessage() ); return $app->json($datas); } if ($e instanceof \Exception_BadRequest) { return new Response('Bad Request', 400); } if ($e instanceof \Exception_NotFound) { return new Response('Not Found', 404); } if ($e instanceof \Exception_Forbidden) { return new Response('Not Found', 403); } }); /** * Temporary fix for https://github.com/fabpot/Silex/issues/438 */ $app['dispatcher']->addListener(KernelEvents::RESPONSE, function(FilterResponseEvent $event){ if ($event->getRequest()->getRequestFormat() == 'json') { $event->getResponse()->setStatusCode(200); } }); return $app; } );