コード例 #1
0
 /**
  * Returns all the competency nodes that must be taken into
  * account when computing level/percentage of parent nodes
  * from a given start node. It includes the node's siblings
  * and parent, and the parent's siblings and parent, and so on.
  *
  * @param Competency $startNode
  * @return array
  */
 public function findForProgressComputing(Competency $startNode)
 {
     if (!($parent = $startNode->getParent())) {
         return [];
     }
     $qb = $this->createQueryBuilder('c');
     return $qb->select('c')->where('c != :startNode')->andWhere('c.root = :root')->andWhere($qb->expr()->orX($qb->expr()->andX('c.lft > :parentLft', 'c.rgt < :parentRgt', 'c.lvl = :childLvl'), 'c.lvl < :childLvl'))->setParameters([':startNode' => $startNode, ':root' => $parent->getRoot(), ':childLvl' => $parent->getLevel() + 1, ':parentLft' => $parent->getLeft(), ':parentRgt' => $parent->getRight()])->getQuery()->getResult();
 }