/** * @param Site $site * @return array */ public function findAllByParentSites(Site $site) { $siteIds = $site->getParentSiteIds(); array_push($siteIds, $site->getId()); $q = $this->createQueryBuilder('q')->where('q.site IN (:site_ids)')->setParameter('site_ids', $siteIds)->getQuery(); $results = $q->getResult(); return $results; }
/** * @param Site $site * @return mixed */ public function countBySite(Site $site) { $siteIds = $site->getParentSiteIds(); array_push($siteIds, $site->getId()); $q = $this->createQueryBuilder('o')->select('count(o.id)')->where('o.site IN (:site_ids)')->setParameter('site_ids', $siteIds)->getQuery(); return $q->getSingleScalarResult(); }