public function getTopicByIdOrName($topicIdOrName, $locale = null)
{
$qb = $this->getQueryBuilder()->select('t', 'tt', 'p')->from($this->getEntityName(), 't')->leftJoin('t.translations', 'tt')->leftJoin('t.parent', 'p')->where("tt.field = 'title'");
if (is_numeric($topicIdOrName)) {
$qb->andWhere('t.id = :id')->setParameter('id', $topicIdOrName);
} else {
$qb->andWhere('t.title = :title')->setParameter('title', $topicIdOrName);
}
if (is_numeric($locale)) {
$language = $this->_em->getReference('Newscoop\\Entity\\Language', $locale);
$locale = $language->getCode();
}
$topic = $this->setTranslatableHint($qb->getQuery(), $locale);
return $topic;
}