Ejemplo n.º 1
0
 public function removeAction($id)
 {
     $userTrack = $this->userTrackRepository->find($id);
     if ($userTrack == null) {
         $this->logger->error("There is no user track with id {$id}.");
         throw new JsonException("Invalid track id.");
     }
     $this->userTrackRepository->remove($userTrack)->flush();
 }
 public function listAction($trackId)
 {
     $userTrack = $this->userTrackRepository->find($trackId);
     if ($userTrack == null) {
         $this->logger->error("There is no user track with id = {$trackId}.");
         throw new JsonException("Invalid id.");
     }
     $track = $userTrack->getGlobalTrack();
     if ($track == null) {
         throw \MetaPlayer\Model\ModelException::thereIsNoGlobalObject($track, 'Track');
     }
     $result = array();
     $associations = $this->associationRepository->findByTrack($track);
     foreach ($associations as $association) {
         $result[] = $this->associationHelper->convertAssociationToDto($association);
     }
     return new JsonViewModel($result, $this->jsonUtils);
 }