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')));
     }
 }