Exemple #1
0
 /**
  * @test
  */
 public function removeTagFromObjectStorageHoldingTags()
 {
     $tag = new \Lobacher\Simpleblog\Domain\Model\Tag();
     $tagsObjectStorageMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array('detach'), array(), '', FALSE);
     $tagsObjectStorageMock->expects($this->once())->method('detach')->with($this->equalTo($tag));
     $this->inject($this->subject, 'tags', $tagsObjectStorageMock);
     $this->subject->removeTag($tag);
 }
 /**
  * ajax action - deletes a post in the repository
  *
  * @param \Lobacher\Simpleblog\Domain\Model\Post $post
  * @param \Lobacher\Simpleblog\Domain\Model\
  * @return bool|string
  */
 public function ajaxAction(Post $post, Comment $comment = NULL)
 {
     if ($comment->getComment() == '') {
         return FALSE;
     }
     $comment->setCommentdate(new \DateTime());
     $post->addComment($comment);
     $this->postRepository->update($post);
     $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
     $comments = $post->getComments();
     foreach ($comments as $comment) {
         $json[$comment->getUid()] = array('comment' => $comment->getComment(), 'commentdate' => $comment->getCommentdate());
     }
     return json_encode($json);
 }
 /**
  * Ajax action - deletes a post in the repository
  *
  * @param \Lobacher\Simpleblog\Domain\Model\Post $post
  * @param \Lobacher\Simpleblog\Domain\Model\Comment $comment
  *
  * @return bool|string
  */
 public function ajaxAction(\Lobacher\Simpleblog\Domain\Model\Post $post, \Lobacher\Simpleblog\Domain\Model\Comment $comment = NULL)
 {
     file_put_contents('./debug.txt', print_r($comment, true), FILE_APPEND);
     file_put_contents('./debug.txt', print_r("\n-----------------\n", true), FILE_APPEND);
     if ($comment->getComment() == "") {
         return FALSE;
     }
     // set datetime of comment and add comment to Post
     $comment->setCommentdate(new \DateTime());
     $post->addComment($comment);
     // signal for comments
     $this->signalSlotDispatcher->dispatch(__CLASS__, 'beforeCommentCreation', array($comment, $post));
     $this->postRepository->update($post);
     $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
     $comments = $post->getComments();
     foreach ($comments as $comment) {
         $json[$comment->getUid()] = array('comment' => $comment->getComment(), 'commentdate' => $comment->getCommentdate());
     }
     return json_encode($json);
 }