コード例 #1
0
 public function startAction()
 {
     $this->layout('layout/chat_layout.phtml');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $qb = $this->getEntityManager()->getRepository("Application\\Entity\\Chat")->createQueryBuilder('c');
         $newChat = rand(1, 1000000);
         $chat = $qb->select()->where('c.chatId = ' . $newChat)->getQuery()->getResult();
         while (!empty($chat)) {
             $newChat = rand(1, 1000000);
             $chat = $qb->select()->where('c.chatId = ' . $newChat)->getQuery()->getResult();
         }
         $chat = new Chat();
         $chat->setChatId($newChat);
         $chat->setChatActive(1);
         $chat->setChatCreated(new \DateTime('now'));
         $this->getEntityManager()->persist($chat);
         $this->getEntityManager()->flush();
         return new ViewModel(array('newChat' => $newChat, 'username' => $request->getPost('username')));
     }
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function setChatActive($chatActive)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setChatActive', array($chatActive));
     return parent::setChatActive($chatActive);
 }