/** * Ajax action - Add more comments * * @param \Vendor\Guestbook\Domain\Model\Comment $comment * * @return bool|string */ public function ajaxAddCommentAction(\Vendor\Guestbook\Domain\Model\Comment $comment = NULL) { if ($comment->getComment() == "") { return FALSE; } // set datetime of comment and add comment to Post $comment->setCommentdate(new \DateTime()); /* @var \Vendor\Guestbook\Domain\Model\Author $author */ $author = $this->objectManager->get('Vendor\\Guestbook\\Domain\\Repository\\AuthorRepository')->findOneByUid($GLOBALS['TSFE']->fe_user->user['uid']); $comment->setAuthor($author); $this->commentRepository->add($comment); $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll(); $this->commentRepository->update($comment); $comments = $this->commentRepository->findAll(); foreach ($comments as $comment) { $json[$comment->getUid()] = array('comment' => $comment->getComment(), 'commentdate' => $comment->getCommentdate(), 'author' => array('fullname' => $comment->getAuthor()->getFullname(), 'email' => $comment->getAuthor()->getEmail(), 'image' => $comment->getAuthor()->getImage())); } return json_encode($json); }
/** * @test */ public function setAuthorForAuthorSetsAuthor() { $authorFixture = new \Vendor\Guestbook\Domain\Model\Author(); $this->subject->setAuthor($authorFixture); $this->assertAttributeEquals($authorFixture, 'author', $this->subject); }