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

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

{@inheritDoc}
public getRootNodes ( $locale = null, $childrenLevel = false, $sortByField = null, $direction = 'asc' )
    public function getRootNodes($locale = null, $childrenLevel = false, $sortByField = null, $direction = 'asc')
    {
        $meta = $this->getClassMetadata();
        $config = $this->listener->getConfiguration($this->_em, $meta->name);
        $qb = $this->getQueryBuilder();
        $qb->select('node', 't', 'c')->from($config['useObjectClass'], 'node')->leftJoin('node.translations', 't')->leftJoin('node.children', 'c');
        if (!$childrenLevel) {
            $qb->where($qb->expr()->isNull('node.' . $config['parent']));
        } else {
            $qb->where($qb->expr()->isNull('node.' . $config['parent']));
        }
        if ($sortByField !== null) {
            $qb->orderBy('node.' . $sortByField, strtolower($direction) === 'asc' ? 'asc' : 'desc');
        } else {
            $qb->orderBy('node.' . $config['left'], 'ASC');
        }
        return $this->setTranslatableHint($qb->getQuery(), $locale);
    }