|
|
|
@ -37,4 +37,30 @@ class BranchSyncRepository extends NestedTreeRepository |
|
|
|
|
|
|
|
|
|
return $q->execute(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the first branch with parent_id = NULL. |
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
|
public function getTopBranch() |
|
|
|
|
{ |
|
|
|
|
$qb = $this->createQueryBuilder('a'); |
|
|
|
|
|
|
|
|
|
//Selecting user info |
|
|
|
|
$qb->select('DISTINCT b'); |
|
|
|
|
|
|
|
|
|
$qb->from('Chamilo\CoreBundle\Entity\BranchSync', 'b'); |
|
|
|
|
$qb->where('b.parentId IS NULL'); |
|
|
|
|
$qb->add('orderBy', 'b.id ASC'); |
|
|
|
|
$qb->setMaxResults(1); |
|
|
|
|
$q = $qb->getQuery()->getResult(); |
|
|
|
|
if (empty($q)) { |
|
|
|
|
return null; |
|
|
|
|
} else { |
|
|
|
|
foreach ($q as $result) { |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|