コード例 #1
0
 /**
  * Populates the specified user track with values from dto.
  * @param \MetaPlayer\Model\UserTrack $userTrack
  * @param TrackDto $dto
  */
 public function populateUserTrackWithDto(UserTrack $userTrack, TrackDto $dto)
 {
     $userTrack->setTitle($this->trimText($dto->title));
     $userTrack->setDuration($this->parseInt($dto->duration));
     $userTrack->setSerial($this->parseInt($dto->serial));
     $userTrack->setSource($dto->source);
 }
コード例 #2
0
 /**
  * @param AssociationDto $dto
  * @param UserTrack $userTrack
  * @throws \MetaPlayer\Model\ModelException
  * @return \MetaPlayer\Model\Association
  */
 public function convertDtoToAssociation(AssociationDto $dto, UserTrack $userTrack)
 {
     $socialNetwork = $this->securityManager->getSocialNetwork();
     $track = $userTrack->getGlobalTrack();
     if ($track == null) {
         throw ModelException::thereIsNoGlobalObject($userTrack, 'Track');
     }
     return new Association($track, $socialNetwork, $dto->socialId);
 }
コード例 #3
0
 private function checkAssociation(UserTrack $userTrack)
 {
     $association = $userTrack->getAssociation($this->securityManager->getSocialNetwork());
     if ($association == null) {
         $track = $userTrack->getGlobalTrack();
         if ($track == null) {
             throw ModelException::thereIsNoGlobalObject($userTrack, 'Track');
         }
         $association = $this->associationRepository->findOnePopularByTrack($userTrack->getGlobalTrack());
         if ($association != null) {
             $userTrack->associate($this->securityManager->getSocialNetwork(), $association);
         }
     }
 }