/** * @return Symfony\Component\HttpFoundation\Response */ public function indexAction() { $visitor = $this->getVisitorByKey(); if ($this->getOperator()) { $this->getResponse()->setContent('No chat found.'); return $this->getResponse(); } if ($this->getRequest()->getMethod() == 'POST') { $visitor->setEmail($this->getRequest()->get('email')); $visitor->setName($this->getRequest()->get('name')); $this->getDocumentManager()->persist($visitor); /* @var $chatSession ServerGrove\SGLiveChatBundle\Document\Session */ $chatSession = new Session(); $chatSession->setRemoteAddr($visitor->getRemoteAddr()); $chatSession->setVisitor($visitor); $visit = $this->getVisitByKey($visitor); $chatSession->setVisit($visit); $chatSession->setStatusId(Session::STATUS_WAITING); $chatSession->setQuestion($this->getRequest()->get('question')); $this->getDocumentManager()->persist($chatSession); $this->getDocumentManager()->flush(); $this->getSessionStorage()->set('chatsession', $chatSession->getId()); $this->cacheUserForSession($visitor, $chatSession); return $this->redirect($this->generateUrl('sglc_chat_load', array('id' => $chatSession->getId()))); } return $this->renderTemplate('SGLiveChatBundle:Chat:index.html.twig', array('visitor' => $visitor, 'errorMsg' => $this->getSessionStorage()->getFlash('errorMsg', null))); }