Example #1
0
 /**
  *
  *
  * @param Request     $request
  * @param Application $app
  * @param string      $hash
  * @return Response
  * @todo Add handling of "play now" if it was moved to position 0
  */
 public function update(Request $request, Application $app, \string $hash) : Response
 {
     if (!($file = $app->getMusicFiles()->getMusicFileByHash($hash))) {
         throw new Exception(Response::HTTP_NOT_FOUND, "File not found.");
     }
     $position = $request->request->get('position');
     $playlist = $app->getPlaylist();
     if ($position) {
         $playlist->moveToPosition($file, $position);
         $playlist->vote($file, self::ADMIN_VOTE_AMOUNT, true);
         $playlist->save();
     }
     return $this->toJson($file);
 }
Example #2
0
 /**
  *
  *
  * @return int
  * @VirtualProperty
  */
 public function votes()
 {
     return $this->app->getPlaylist()->getVotes($this);
 }