/** * Hydrates a user object with the data * * @param array $data * @param User $object * * @return User */ public function hydrate(array $data, User $object) { $object->setEmail($data['email']); $object->setName($data['name']); $object->setSendNotifications($data['sendNotifications']); if (isset($data['timezone'])) { if (!$data['timezone'] instanceof \DateTimeZone) { $object->setTimezone(new \DateTimeZone($data['timezone'])); } else { $object->setTimezone($data['timezone']); } } $object->setIsMentee($data['isMentee']); $object->setIsMentor($data['isMentor']); if (isset($data['isEnabled'])) { $object->setIsEnabled($data['isEnabled']); } if (isset($data['githubUid'])) { $object->setGithubUid($data['githubUid']); } if (isset($data['githubName'])) { $object->setGithubName($data['githubName']); } if (isset($data['timeCreated'])) { if (!$data['timeCreated'] instanceof \DateTime) { $createdTime = new \DateTime($data['timeCreated']); $object->setTimeCreated($createdTime); } else { $object->setTimeCreated($data['timeCreated']); } } if (isset($data['id'])) { $object->setId($data['id']); } if (isset($data['roles'])) { if (is_array($data['roles'])) { $object->setRoles($data['roles']); } else { $object->setRoles(unserialize($data['roles'])); } } if (isset($data['profile'])) { $object->setProfile($data['profile']); } $mentoringTerm = $this->taxonomyService->fetchVocabularyByName('mentor'); $apprenticeTerm = $this->taxonomyService->fetchVocabularyByName('apprentice'); $object->setMentorTags($this->taxonomyService->fetchTermsForUser($object, $mentoringTerm)); $object->setApprenticeTags($this->taxonomyService->fetchTermsForUser($object, $apprenticeTerm)); return $object; }