public function linkCompetency(Objective $objective, Competency $competency, Level $level)
    {
        $link = $this->objectiveCompetencyRepo->findOneBy([
            'competency' => $competency,
            'objective' => $objective,
        ]);

        if ($link) {
            return false;
        }

        $framework = $this->competencyRepo->findOneBy(['root' => $competency->getRoot()]);

        if ($level->getScale() !== $framework->getScale()) {
            throw new \LogicException(
                'Objective level must belong to the root competency scale'
            );
        }

        $link = new ObjectiveCompetency();
        $link->setObjective($objective);
        $link->setCompetency($competency);
        $link->setLevel($level);
        $link->setFramework($framework);

        $this->om->persist($link);
        $this->om->flush();

        $this->progressManager->recomputeObjectiveProgress($objective);

        $competency = $this->competencyManager->loadCompetency($competency);
        $competency['id'] = $link->getId(); // link is treated as the competency itself on client-side
        $competency['framework'] = $framework->getName();
        $competency['level'] = $level->getName();

        return $competency;
    }
public function linkCompetency(Objective $objective, Competency $competency, Level $level)
    {
        $link = $this->objectiveCompetencyRepo->findOneBy([
            'competency' => $competency,
            'objective' => $objective,
        ]);

        if ($link) {
            return false;
        }

        $framework = $this->competencyRepo->findOneBy(['root' => $competency->getRoot()]);

        if ($level->getScale() !== $framework->getScale()) {
            throw new \LogicException(
                'Objective level must belong to the root competency scale'
            );
        }

        $link = new ObjectiveCompetency();
        $link->setObjective($objective);
        $link->setCompetency($competency);
        $link->setLevel($level);
        $link->setFramework($framework);

        $this->om->persist($link);
        $this->om->flush();

        $this->progressManager->recomputeObjectiveProgress($objective);

        $competency = $this->competencyManager->loadCompetency($competency);
        $competency['id'] = $link->getId(); // link is treated as the competency itself on client-side
        $competency['framework'] = $framework->getName();
        $competency['level'] = $level->getName();

        return $competency;
    }
public function linkCompetency ( Objective $ objective , Competency $ competency , Level $ level ) { $ link = $ this -> objectiveCompetencyRepo -> findOneBy ( [ 'competency' => $ competency , 'objective' => $ objective , ] ) ; if ( $ link ) { return false ; } $ framework = $ this -> competencyRepo -> findOneBy ( [ 'root' => $ competency -> getRoot ( ) ] ) ; if ( $ level -> getScale ( ) !== $ framework -> getScale ( ) ) { throw new \ LogicException ( 'Objective level must belong to the root competency scale' ) ; } $ link = new ObjectiveCompetency ( ) ; $ link -> setObjective ( $ objective ) ; $ link -> setCompetency ( $ competency ) ; $ link -> setLevel ( $ level ) ; $ link -> setFramework ( $ framework ) ; $ this -> om -> persist ( $ link ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeObjectiveProgress ( $ objective ) ; $ competency = $ this -> competencyManager -> loadCompetency ( $ competency ) ; $ competency [ 'id' ] = $ link -> getId ( ) ; // link is treated as the competency itself on client-side $ competency [ 'framework' ] = $ framework -> getName ( ) ; $ competency [ 'level' ] = $ level -> getName ( ) ; return $ competency ; }
Creates an association between an objective and a competency,
with an expected level. Returns a full array representation of
the newly associated competency if the link doesn't already exist.
Otherwise, returns false.

@param Objective  $objective
@param Competency $competency
@param Level      $level

@return mixed array|bool

@throws \LogicException if the level doesn't belong to the root competency scale
Creates an association between an objective and a competency with an expected level . Returns a full array representation of the newly associated competency if the link doesn t already exist . Otherwise returns false .