BlogBundle/Twig/BlogExtension.php
public function getCarouselItemsBlog($entity)
    {
        $em = $this->container->get('doctrine')->getManager();
        
        if($entity instanceof Category){
            $qb = $em->getRepository('BlogBundle:Post')
                ->createQueryBuilder('p')
                ->join('p.categories', 'c')
                ->join('p.translations', 't')
                ->where('c.id = :category')
                ->andWhere('p.highlighted = true')
                ->setParameter('category', $entity->getId())
                ->setMaxResults(3)
                ->orderBy('p.published', 'DESC');
        }elseif($entity instanceof Tag){
            $qb = $em->getRepository('BlogBundle:Post')
                ->createQueryBuilder('p')
                ->join('p.tags', 'tag')
                ->join('p.translations', 't')
                ->where('t.id = :tag')
                ->andWhere('p.highlighted = true')
                ->setParameter('tag', $entity->getId())
                ->setMaxResults(3)
                ->orderBy('p.published', 'DESC');
        }
        
        $entities = $qb->getQuery()->getResult();
        return $entities;
    }
public function getCarouselItemsBlog($entity)
    {
        $em = $this->container->get('doctrine')->getManager();
        
        if($entity instanceof Category){
            $qb = $em->getRepository('BlogBundle:Post')
                ->createQueryBuilder('p')
                ->join('p.categories', 'c')
                ->join('p.translations', 't')
                ->where('c.id = :category')
                ->andWhere('p.highlighted = true')
                ->setParameter('category', $entity->getId())
                ->setMaxResults(3)
                ->orderBy('p.published', 'DESC');
        }elseif($entity instanceof Tag){
            $qb = $em->getRepository('BlogBundle:Post')
                ->createQueryBuilder('p')
                ->join('p.tags', 'tag')
                ->join('p.translations', 't')
                ->where('t.id = :tag')
                ->andWhere('p.highlighted = true')
                ->setParameter('tag', $entity->getId())
                ->setMaxResults(3)
                ->orderBy('p.published', 'DESC');
        }
        
        $entities = $qb->getQuery()->getResult();
        return $entities;
    }
Returns all items from blog category.

@return ArrayCollection