コード例 #1
0
ファイル: PersistTchat.php プロジェクト: teraelis/forum
 function persistMessage(Message $message)
 {
     $em = $this->doctrine->getManager();
     $em->persist($message);
     $em->flush();
     $salon = $message->getSalon();
     $usersToNotify = $salon->getUsers();
     foreach ($usersToNotify as $user) {
         if ($user->getId() != $message->getUser()->getId()) {
             $nonVu = new NonVuTChat();
             $nonVu->setUser($user);
             $nonVu->setSalon($salon);
             $em->persist($nonVu);
         }
     }
     $usersToNotify = $salon->getMods();
     foreach ($usersToNotify as $user) {
         if ($user->getId() != $message->getUser()->getId()) {
             $nonVu = new NonVuTChat();
             $nonVu->setUser($user);
             $nonVu->setSalon($salon);
             $em->persist($nonVu);
         }
     }
     $em->flush();
     $salon->setLastUpdate(new \DateTime());
     $em->persist($salon);
     $em->flush();
 }
コード例 #2
0
ファイル: SalonManager.php プロジェクト: teraelis/forum
 /**
  * @param Salon  $salon
  * @param User[] $users
  * @param User[] $mods
  * @param bool   $isPrivate
  * @return Salon
  */
 public function createSalon(Salon $salon, $users, $mods, $isPrivate)
 {
     $salon->resetUsers();
     foreach ($users as $u) {
         $salon->addUser($u);
     }
     foreach ($mods as $m) {
         $salon->addMod($m);
     }
     $salon->setPrivate($isPrivate);
     $this->em->persist($salon);
     $this->em->flush();
     foreach ($users as $u) {
         $nv = new NonVuTChat();
         $nv->setSalon($salon);
         $nv->setUser($u);
         $this->em->persist($nv);
     }
     $this->em->flush();
     return $salon;
 }