/** * @param \MetaPlayer\Model\UserTrack $userTrack * @return TrackDto */ public function convertUserTrackToDto(\MetaPlayer\Model\UserTrack $userTrack) { $dto = $this->convertBaseTrackToDto($userTrack); $dto->id = $userTrack->getId(); $dto->albumId = $userTrack->getUserAlbum()->getId(); $dto->source = $userTrack->getSource(); $association = $userTrack->getAssociation($this->securityManager->getSocialNetwork()); if ($association != null) { $dto->association = $this->associationHelper->convertAssociationToDto($association); $dto->association->userTrackId = $userTrack->getId(); } $dto->shareId = "t" . $userTrack->getGlobalTrack()->getId(); return $dto; }
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); }