Skip to content

Commit

Permalink
Merge pull request sonata-project#182 from eko/master
Browse files Browse the repository at this point in the history
Fix post comment add method
  • Loading branch information
rande committed Mar 12, 2014
2 parents e70a1c4 + 036d701 commit 4f7f11c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Controller/Api/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,17 @@ public function postPostCommentsAction($id, Request $request)
}

$comment = $this->commentManager->create();
$comment->setPost($post);
$comment->setStatus($post->getCommentsDefaultStatus());

$form = $this->formFactory->createNamed(null, 'sonata_news_api_form_comment', $comment, array('csrf_protection' => false));
$form->bind($request);

if ($form->isValid()) {
$comment = $form->getData();
$comment->setPost($post);

if (!$comment->getStatus()) {
$comment->setStatus($post->getCommentsDefaultStatus());
}

$this->commentManager->save($comment);
$this->mailer->sendCommentNotification($comment);
Expand Down

0 comments on commit 4f7f11c

Please sign in to comment.