/** * * * @param Request $request * @param \MP\Application $app */ public function before(Request $request, \MP\Application $app) { if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) { $data = json_decode($request->getContent(), true); $request->request->replace(is_array($data) ? $data : array()); } $app->error(function (HttpException $e) use($app) { return $app->json(["error" => $e->getMessage()], $e->getStatusCode(), ['Content-Type' => 'application/json']); }); }
/** * * * @param Request $request * @param Application $app * @return Response */ public function getArtists(Request $request, Application $app) : Response { return $this->toJson($app->getMusicFiles()->getArtists()); }
/** * @param Request $request * @param Application $app * @return Response */ public function index(Request $request, Application $app) : Response { return $app->render('index.twig', ['isDev' => $app->isDev(), 'isAdmin' => $app->isAdmin($request), 'language' => $app->getTranslator()->getLocale(), 'languages' => $app->getTranslationService()->getLanguages()]); }
/** * * * @return int * @VirtualProperty */ public function votes() { return $this->app->getPlaylist()->getVotes($this); }
public function setUp() { $this->app = new Application(); $this->app->register(new YamlConfigServiceProvider($this->app->getRootDir() . '/app/config/parameters.yml')); $GLOBALS['app'] = $this->app; }