plugin/competency/Controller/MyObjectiveController.php
public function objectiveCompetencyResourceFetchAction(Competency $competency, $level, User $user)
    {
        $rootComptency = empty($competency->getParent()) ?
            $competency :
            $this->competencyManager->getCompetencyById($competency->getRoot());
        $scale = $rootComptency->getScale();
        $levelEntity = $this->competencyManager->getLevelByScaleAndValue($scale, $level);
        $resource = $this->objectiveManager->getRelevantResourceForUserByLevel($user, $competency, $levelEntity);
        $data = is_null($resource) ? null : ['resourceId' => $resource->getId()];

        return new JsonResponse($data);
    }
public function objectiveCompetencyResourceFetchAction(Competency $competency, $level, User $user)
    {
        $rootComptency = empty($competency->getParent()) ?
            $competency :
            $this->competencyManager->getCompetencyById($competency->getRoot());
        $scale = $rootComptency->getScale();
        $levelEntity = $this->competencyManager->getLevelByScaleAndValue($scale, $level);
        $resource = $this->objectiveManager->getRelevantResourceForUserByLevel($user, $competency, $levelEntity);
        $data = is_null($resource) ? null : ['resourceId' => $resource->getId()];

        return new JsonResponse($data);
    }
public function objectiveCompetencyResourceFetchAction ( Competency $ competency , $ level , User $ user ) { $ rootComptency = empty ( $ competency -> getParent ( ) ) ? $ competency : $ this -> competencyManager -> getCompetencyById ( $ competency -> getRoot ( ) ) ; $ scale = $ rootComptency -> getScale ( ) ; $ levelEntity = $ this -> competencyManager -> getLevelByScaleAndValue ( $ scale , $ level ) ; $ resource = $ this -> objectiveManager -> getRelevantResourceForUserByLevel ( $ user , $ competency , $ levelEntity ) ; $ data = is_null ( $ resource ) ? null : [ 'resourceId' => $ resource -> getId ( ) ] ; return new JsonResponse ( $ data ) ; }
Fetches a resource for a competency at the given level for My Objectives tool.

@EXT\Route(
"/objective/competency/{competency}/level/{level}/resource/fetch",
name="hevinci_my_objectives_competency_resource_fetch"
)
@EXT\ParamConverter("user", options={"authenticatedUser"=true})

@param Competency $competency
@param int        $level
@param User       $user

@return JsonResponse
Fetches a resource for a competency at the given level for My Objectives tool .