/**
  * @param Taggable $taggable
  * @param TagGroup $tagGroup
  *
  * @return Collection
  */
 public function filterByGroup(Taggable $taggable, TagGroup $tagGroup)
 {
     $ids = $this->getTagsIds($taggable);
     if (0 === count($ids)) {
         return new ArrayCollection();
     }
     $qb = $this->createQueryBuilder('tg');
     $qb->select('tg, t');
     $qb->leftJoin('tg.tags', 't');
     $qb->where('tg.id = :id')->setParameter('id', $tagGroup->getId());
     $qb->andWhere($qb->expr()->in('t.id', $ids));
     $qb->orderBy('t.name', 'ASC');
     /** @var TagGroup[] $result */
     $result = $qb->getQuery()->getResult();
     if ($result) {
         return $result[0]->getTags();
     }
     return new ArrayCollection();
 }