function setProfile(Agent $agent) { $this->checkPermission('changeProfile'); if (!$this->equals($agent->user)) { throw new \Exception('error'); } $this->profile = $agent; $agent->setParentAsNull(true); }