Esempio n. 1
0
 /**
  * Associates track with specified the association.
  * @param SocialNetwork $socialNetwork
  * @param Association $association
  * @return \MetaPlayer\Model\UserTrack
  * @throws ModelException
  */
 public function associate(SocialNetwork $socialNetwork, Association $association)
 {
     $prevAssoc = $this->getAssociation($socialNetwork);
     if (isset($prevAssoc)) {
         $prevAssoc->decrementPopularity();
     }
     switch ($socialNetwork) {
         case SocialNetwork::$MY:
             $this->myAssociation = $association;
             break;
         case SocialNetwork::$VK:
             $this->vkAssociation = $association;
             break;
         default:
             throw ModelException::unsupportedSocialNetwork($socialNetwork);
     }
     $association->incrementPopularity();
     return $this;
 }