/**
  * @param Tag $tag
  * @param string $locale
  *
  * @return Query
  */
 public function findPostsByTagAsQuery(Tag $tag, $locale)
 {
     $qb = $this->createQueryBuilder('p');
     $qb->where($qb->expr()->eq('t.id', ':tag_id'))->andWhere($qb->expr()->eq('p.published', true))->leftJoin('p.tags', 't')->setParameter('tag_id', $tag->getId())->orderBy('p.created', 'DESC');
     $this->addLocaleFilter($locale, $qb);
     return $qb->getQuery();
 }
 /**
  * View tag
  *
  * @Route("/blog/tag/{text}/{title}/{page}", name="blog_tag_view",
  *      requirements={"page"="\d+", "title"="page"},
  *      defaults={"page"="1", "title"="page"})
  * @Template()
  *
  * @param Tag $tag
  * @param int $page page number
  *
  * @return array
  */
 public function viewAction(Tag $tag, $page)
 {
     $posts = $this->get('knp_paginator')->paginate($tag->getPosts(), $page, 10);
     if ($this->has('menu.breadcrumbs')) {
         $breadcrumbs = $this->get('menu.breadcrumbs');
         $breadcrumbs->addChild('Блог', $this->get('router')->generate('blog'));
         $breadcrumbs->addChild($tag->getText())->setIsCurrent(true);
     }
     return $this->_getRequestDataWithDisqusShortname(array('tag' => $tag, 'posts' => $posts));
 }
 public function testTagConstructor()
 {
     $text = "symfony2";
     $tag = new Tag('symfony2');
     $this->assertEquals($tag->getText(), $text);
 }