/** * @param TaxonomyInterface $taxonomy * @param Archetype|null $archetype * @return array */ public function getTaxonsAsListByArchetype(TaxonomyInterface $taxonomy, Archetype $archetype = null) { $queryBuilder = $this->getQueryBuilder()->where('o.taxonomy = :taxonomy')->andWhere('o.parent IS NOT NULL')->setParameter('taxonomy', $taxonomy); if ($archetype) { $type = $archetype->getType(); $queryBuilder->andWhere('o.' . $type . 'Archetype =:type')->setParameter('type', $archetype); } return $queryBuilder->orderBy('o.left')->getQuery()->getResult(); }