add() public method

Add command
public add ( array $data, integer $documentId ) : boolean
$data array Array of comments
$documentId integer Document id
return boolean
Beispiel #1
0
 /**
  * Invoke form
  *
  * @return void
  */
 public function __invoke()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         $this->getForm()->setData($post);
         if ($this->getForm()->isValid()) {
             $commentTable = new Blog\Model\Comment();
             $document = $this->getServiceLocator()->get('Zend\\View\\Renderer\\PhpRenderer')->plugin('CurrentDocument');
             if ($commentTable->add($this->getForm()->getInputFilter()->getValues(), $document()->getId())) {
                 $this->flashMessenger()->addSuccessMessage('Message sent');
                 return $this->redirect()->toUrl($request->getRequestUri());
             }
         }
     }
     return $this->addPath(__DIR__ . '/../views')->render('plugin/comment-form.phtml', array('form' => $this->getForm(), 'errorMessage' => 'Error'));
 }
Beispiel #2
0
 /**
  * Test
  *
  * @return void
  */
 public function testAddWithWrongValues()
 {
     $data = array('message' => '', 'username' => '', 'email' => '');
     $this->assertFalse($this->object->add($data, $this->document->getId()));
 }