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

        $select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o';

        $query = $this->createQueryBuilder('o')
            ->select($select)
            ->leftJoin('o.objectiveCompetencies', 'oc')
            ->leftJoin('o.users', 'ou')
            ->leftJoin('o.groups', 'og')
            ->leftJoin(
                'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress',
                'op',
                'WITH',
                'op.user = :user AND op.objective = o'
            )
            ->andWhere($groupQb->expr()->orX(
                'ou = :user',
                $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
            ))
            ->groupBy('o.id')
            ->setParameter(':user', $user)
            ->getQuery();

        return $query->{$asArray ? 'getArrayResult' : 'getResult'}();
    }
public function findByUser(User $user, $asArray = true)
    {
        $groupQb = $this->_em->createQueryBuilder()
            ->select('g')
            ->from('Claroline\CoreBundle\Entity\Group', 'g')
            ->join('g.users', 'gu')
            ->where('gu = :user');

        $select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o';

        $query = $this->createQueryBuilder('o')
            ->select($select)
            ->leftJoin('o.objectiveCompetencies', 'oc')
            ->leftJoin('o.users', 'ou')
            ->leftJoin('o.groups', 'og')
            ->leftJoin(
                'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress',
                'op',
                'WITH',
                'op.user = :user AND op.objective = o'
            )
            ->andWhere($groupQb->expr()->orX(
                'ou = :user',
                $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
            ))
            ->groupBy('o.id')
            ->setParameter(':user', $user)
            ->getQuery();

        return $query->{$asArray ? 'getArrayResult' : 'getResult'}();
    }
public function findByUser ( User $ user , $ asArray = true ) { $ groupQb = $ this -> _em -> createQueryBuilder ( ) -> select ( 'g' ) -> from ( 'Claroline\CoreBundle\Entity\Group' , 'g' ) -> join ( 'g.users' , 'gu' ) -> where ( 'gu = :user' ) ; $ select = $ asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o' ; $ query = $ this -> createQueryBuilder ( 'o' ) -> select ( $ select ) -> leftJoin ( 'o.objectiveCompetencies' , 'oc' ) -> leftJoin ( 'o.users' , 'ou' ) -> leftJoin ( 'o.groups' , 'og' ) -> leftJoin ( 'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress' , 'op' , 'WITH' , 'op.user = :user AND op.objective = o' ) -> andWhere ( $ groupQb -> expr ( ) -> orX ( 'ou = :user' , $ groupQb -> expr ( ) -> in ( 'og' , $ groupQb -> getQuery ( ) -> getDQL ( ) ) ) ) -> groupBy ( 'o.id' ) -> setParameter ( ':user' , $ user ) -> getQuery ( ) ; return $ query -> { $ asArray ? 'getArrayResult' : 'getResult' } ( ) ; }
Returns the objectives assigned to a user. Objectives assigned to
groups whose the user is a member of are also returned.

@param User $user
@param bool $asArray

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