Example #1
0
 /**
  * @param Category $category
  * @return \Doctrine\ORM\QueryBuilder
  *
  * Find all category exepts the childs (recusrive) of $category
  */
 public function findWithoutChilds(Category $category)
 {
     $idArray = [];
     $all = $this->findAll();
     foreach ($all as $one) {
         $idArray[$one->getId()] = $one->getId();
     }
     $childs = $category->getChildsRecursive();
     foreach ($childs as $child) {
         unset($idArray[$child->getId()]);
     }
     unset($idArray[$category->getId()]);
     $query = $this->createQueryBuilder('c')->where('c.id IN (:id)')->setParameter('id', $idArray);
     return $query;
 }