/**
  * @param Thread $thread
  * @param Post $post
  * @return Post
  */
 public function register(Thread $thread, Post $post)
 {
     $thread->addPost($post)->setLastPostedAt($this->currentDate());
     $post->setThread($thread);
     $this->threadRepository->add($thread);
     $this->entityManager->flush();
     return $post;
 }
 /**
  * @param Tags $tags
  * @return array
  */
 public function findByTags(Tags $tags)
 {
     $qb = $this->threadRepository->createQueryBuilder("thread");
     $query = $qb->select()->innerJoin('thread.tags', 'tag', 'WITH', 'tag.name IN (:tag_names)')->setParameter("tag_names", $tags->getNames())->getQuery();
     return $query->getResult();
 }