Newscoop\NewscoopBundle\Entity\Repository\TopicRepository::getTopicByIdOrName PHP Метод

getTopicByIdOrName() публичный Метод

Gets topic by given id or name.
public getTopicByIdOrName ( string | integer $topicIdOrName, string | integer $locale = null ) : Doctrine\ORM\Query
$topicIdOrName string | integer Topicid or name
$locale string | integer Current locale, language code or id
Результат Doctrine\ORM\Query
    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;
    }