plugin/competency/Repository/ObjectiveRepository.php
public function findByCompetencyAndUser(Competency $competency, User $user)
    {
        $groupQb = $this->_em->createQueryBuilder()
            ->select('g')
            ->from('Claroline\CoreBundle\Entity\Group', 'g')
            ->join('g.users', 'gu')
            ->where('gu = :user');

        return $this->createQueryBuilder('o')
            ->select('o')
            ->leftJoin('o.objectiveCompetencies', 'oc')
            ->leftJoin('o.users', 'ou')
            ->leftJoin('o.groups', 'og')
            ->where('oc.competency = :competency')
            ->andWhere($groupQb->expr()->orX(
                'ou = :user',
                $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
            ))
            ->setParameters([
                'competency' => $competency,
                'user' => $user,
            ])
            ->distinct()
            ->getQuery()
            ->getResult();
    }
public function findByCompetencyAndUser(Competency $competency, User $user)
    {
        $groupQb = $this->_em->createQueryBuilder()
            ->select('g')
            ->from('Claroline\CoreBundle\Entity\Group', 'g')
            ->join('g.users', 'gu')
            ->where('gu = :user');

        return $this->createQueryBuilder('o')
            ->select('o')
            ->leftJoin('o.objectiveCompetencies', 'oc')
            ->leftJoin('o.users', 'ou')
            ->leftJoin('o.groups', 'og')
            ->where('oc.competency = :competency')
            ->andWhere($groupQb->expr()->orX(
                'ou = :user',
                $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
            ))
            ->setParameters([
                'competency' => $competency,
                'user' => $user,
            ])
            ->distinct()
            ->getQuery()
            ->getResult();
    }
public function findByCompetencyAndUser ( Competency $ competency , User $ user ) { $ groupQb = $ this -> _em -> createQueryBuilder ( ) -> select ( 'g' ) -> from ( 'Claroline\CoreBundle\Entity\Group' , 'g' ) -> join ( 'g.users' , 'gu' ) -> where ( 'gu = :user' ) ; return $ this -> createQueryBuilder ( 'o' ) -> select ( 'o' ) -> leftJoin ( 'o.objectiveCompetencies' , 'oc' ) -> leftJoin ( 'o.users' , 'ou' ) -> leftJoin ( 'o.groups' , 'og' ) -> where ( 'oc.competency = :competency' ) -> andWhere ( $ groupQb -> expr ( ) -> orX ( 'ou = :user' , $ groupQb -> expr ( ) -> in ( 'og' , $ groupQb -> getQuery ( ) -> getDQL ( ) ) ) ) -> setParameters ( [ 'competency' => $ competency , 'user' => $ user , ] ) -> distinct ( ) -> getQuery ( ) -> getResult ( ) ; }
Returns the objectives assigned to a user which includes a
given competency. Objectives assigned to groups whose the
user is a member of are also returned.

@param Competency $competency
@param User       $user

@return array
Returns the objectives assigned to a user which includes a given competency . Objectives assigned to groups whose the user is a member of are also returned .