예제 #1
0
 /**
  * @param User    $user
  * @param Thread  $thread
  * @param integer $inviter
  */
 public function __construct($user, $thread, $inviter)
 {
     $this->user = $user;
     $this->thread = $thread;
     $this->inviter = $inviter;
     $user->addUserThread($this);
     $thread->addUserThread($this);
 }
예제 #2
0
 private function createDialog(User $user, User $recipientUser)
 {
     $thread = $this->em->getRepository('NetworkStoreBundle:Thread')->findByUsers($user->getId(), $recipientUser->getId());
     if (!$thread or count($thread) == 0) {
         // there's no 1x1 thread between this pair of users
         // so we're creating a new one
         $thread = new Thread();
         $thread->setTopic('no topic');
         $this->persistAndFlush($thread);
         //because of foreign key error
         $thread->addUser($user, $user->getId())->addUser($recipientUser, $user->getId());
         $this->persistAndFlush($thread);
     } elseif (count($thread) > 1) {
         throw new Exception('SERVER ERROR: 2 dialogs between 2 persons');
     } else {
         $thread = $thread[0];
     }
     return $thread;
 }