private function handleForm(Zend_Form $p_form, Comment $p_comment) { if ($this->getRequest()->isPost() && $p_form->isValid($_POST)) { $values = $p_form->getValues(); $values['ip'] = $this->getRequest()->getClientIp(); $values['status'] = 'hidden'; $values['time_created'] = new DateTime(); $this->commentRepository->save($p_comment, $values); $this->commentRepository->flush(); $this->_helper->flashMessenger(getGS('Comment "$1" saved.', $p_comment->getSubject())); $this->_helper->redirector->gotoSimple('index'); } }
private function handleForm(Zend_Form $p_form, Comment $p_comment) { $translator = \Zend_Registry::get('container')->getService('translator'); if ($this->getRequest()->isPost() && $p_form->isValid($_POST)) { $values = $p_form->getValues(); $values['ip'] = $this->getRequest()->getClientIp(); $values['status'] = 'hidden'; $values['time_created'] = new DateTime(); $this->commentRepository->save($p_comment, $values); $this->commentRepository->flush(); $this->_helper->flashMessenger($translator->trans('Comment $1 saved.', array('$1' => $p_comment->getSubject()), 'comments')); $this->_helper->redirector->gotoSimple('index'); } }
/** * @ticket CS-3872 */ public function testSaveWithoutParentOrder() { $language = new Language(); $this->em->persist($language); $this->em->flush(); $publication = new Publication(); $this->em->persist($publication); $this->em->flush(); $article = new Article(2, $language); $article->setPublication($publication); $this->em->persist($article); $this->em->flush(); $user = new User(); $user->setUsername('testname'); $user->setEmail('testmail'); $this->em->persist($user); $this->em->flush(); $values = array('user' => $user, 'name' => 'testUser', 'subject' => 'testSubject', 'message' => 'testMessage', 'language' => $language->getId(), 'thread' => $article->getNumber(), 'ip' => '127.0.0.1', 'status' => 'approved', 'time_created' => new \DateTime()); $comment = $this->repository->save(new Comment(), $values); $this->em->flush(); $this->assertEquals(1, $comment->getThreadOrder()); $comment = $this->repository->save(new Comment(), $values); $this->assertEquals(2, $comment->getThreadOrder()); }