/
TagController.php
33 lines (28 loc) · 1.04 KB
/
TagController.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
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\BrowserKit\Response;
use Symfony\Component\HttpFoundation\Request;
class TagController extends Controller
{
/**
* @Route("/{_locale}/tag", name="posts_by_tag", defaults={"_locale": "en"}, requirements={
* "_locale": "%locales.variants%"
* })
* @Method("GET")
* @Template()
*/
public function indexAction(Request $request)
{
$postManager = $this->container->get('app.post_manager');
$pagination = $postManager->getPostsByTag($request);
if ($request->isXmlHttpRequest()) {
$content = $this->renderView('AppBundle:Common:renderPostList.html.twig',['posts' => $pagination]);
return new Response($content);
}
return ['posts' => $pagination];
}
}