From 6042c05cb03e0075f81766e8a8959a967998e3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=BCbner?= Date: Thu, 13 Apr 2017 18:59:59 +0200 Subject: [PATCH] Add findSubthemes function --- .../Repository/Rebrickable/ThemeRepository.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/AppBundle/Repository/Rebrickable/ThemeRepository.php b/src/AppBundle/Repository/Rebrickable/ThemeRepository.php index 11b0d88..8752161 100644 --- a/src/AppBundle/Repository/Rebrickable/ThemeRepository.php +++ b/src/AppBundle/Repository/Rebrickable/ThemeRepository.php @@ -2,8 +2,21 @@ namespace AppBundle\Repository\Rebrickable; +use AppBundle\Entity\Rebrickable\Theme; use AppBundle\Repository\BaseRepository; +use Doctrine\ORM\Query\Expr\Join; class ThemeRepository extends BaseRepository { + public function findAllSubthemes(Theme $theme) { + + $subQueryBuilder = $this->createQueryBuilder('subtheme'); + + $queryBuilder = $this->createQueryBuilder('subtheme') + ->leftJoin(Theme::class,'theme', Join::WITH, 'subtheme.parent = theme.id') + ->where('subtheme.parent = :id') + ->setParameter('id', $theme->getId()); + + return $queryBuilder->getQuery()->getResult(); + } }