public function assignObjective(Objective $objective, $subject)
    {
        $target = $this->getSubjectType($subject);
        $hasMethod = "has{$target}";
        $addMethod = "add{$target}";

        if ($objective->{$hasMethod}($subject)) {
            return false;
        }

        $objective->{$addMethod}($subject);
        $this->om->flush();

        $this->progressManager->recomputeUserProgress($subject);

        return true;
    }
public function assignObjective(Objective $objective, $subject)
    {
        $target = $this->getSubjectType($subject);
        $hasMethod = "has{$target}";
        $addMethod = "add{$target}";

        if ($objective->{$hasMethod}($subject)) {
            return false;
        }

        $objective->{$addMethod}($subject);
        $this->om->flush();

        $this->progressManager->recomputeUserProgress($subject);

        return true;
    }
public function assignObjective ( Objective $ objective , $ subject ) { $ target = $ this -> getSubjectType ( $ subject ) ; $ hasMethod = "has{$target}" ; $ addMethod = "add{$target}" ; if ( $ objective -> { $ hasMethod } ( $ subject ) ) { return false ; } $ objective -> { $ addMethod } ( $ subject ) ; $ this -> om -> flush ( ) ; $ this -> progressManager -> recomputeUserProgress ( $ subject ) ; return true ; }
Assigns an objective to a user or a group. If the objective has already
been assigned, returns false. Otherwise, returns true.

@param Objective  $objective
@param User|Group $subject

@return bool

@throws \Exception if the subject is not an instance of User or Group
Assigns an objective to a user or a group . If the objective has already been assigned returns false . Otherwise returns true .