示例#1
0
 /**
  *
  *
  * @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']);
     });
 }
示例#2
0
 /**
  *
  *
  * @param Request     $request
  * @param Application $app
  * @return Response
  */
 public function getArtists(Request $request, Application $app) : Response
 {
     return $this->toJson($app->getMusicFiles()->getArtists());
 }
示例#3
0
 /**
  * @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()]);
 }
示例#4
0
 /**
  *
  *
  * @return int
  * @VirtualProperty
  */
 public function votes()
 {
     return $this->app->getPlaylist()->getVotes($this);
 }
示例#5
0
 public function setUp()
 {
     $this->app = new Application();
     $this->app->register(new YamlConfigServiceProvider($this->app->getRootDir() . '/app/config/parameters.yml'));
     $GLOBALS['app'] = $this->app;
 }