Minor - update from 1.11.x

pull/2650/head
Julio Montoya 6 years ago
parent e59ca4d718
commit b858e3835f
  1. 26
      src/CoreBundle/Repository/BranchSyncRepository.php

@ -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;
}
}
}
}

Loading…
Cancel
Save