Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
         }
     }
 }