forked from stfalcon/BlogBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommentController.php
40 lines (33 loc) · 1.26 KB
/
CommentController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Stfalcon\Bundle\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Stfalcon\Bundle\BlogBundle\Entity\Post;
/**
* Controller for actions with DISQUS comments
*
* @author Stepan Tanasiychuk <ceo@stfalcon.com>
*/
class CommentController extends Controller
{
/**
* Synchronization comments count with disqus
*
* @param Post $post Post object
*
* @return Response
* @Route("/blog/post/{slug}/disqus-sync", name="blog_post_disqus_sync")
*/
public function disqusSyncAction(Post $post)
{
// @todo. нужно доставать полный список ЗААПРУВЛЕННЫХ комментариев или
// колличество комментариев к записи (если такой метод появится в API disqus)
// после чего обновлять их колличество в БД
$post->setCommentsCount($post->getCommentsCount() + 1);
$em = $this->get('doctrine.orm.entity_manager');
$em->persist($post);
$em->flush($post);
return new Response(json_encode('ok'));
}
}