Esempio n. 1
0
 /**
  * Extracts and returns the user data from the user object
  *
  * @param  User $object
  * @return array
  */
 public function extract(User $object)
 {
     $data = ['email' => $object->getEmail(), 'id' => $object->getId(), 'name' => $object->getName(), 'roles' => $object->getRoles(), 'timeCreated' => $object->getTimeCreated(), 'isEnabled' => $object->isEnabled(), 'githubUid' => $object->getGithubUid(), 'githubName' => $object->getGithubName(), 'isMentee' => $object->isMentee(), 'isMentor' => $object->isMentor(), 'profile' => $object->getProfile(), 'apprenticeTags' => $object->getApprenticeTags(), 'mentorTags' => $object->getMentorTags(), 'imageUrl' => $object->getProfileImage(), 'timezone' => $object->getTimezone(), 'sendNotifications' => $object->hasSendNotifications()];
     if (!is_null($this->termHydrator)) {
         $apprenticeTags = $data['apprenticeTags'];
         unset($data['apprenticeTags']);
         foreach ($apprenticeTags as $key => $tag) {
             $tag = $this->termHydrator->extract($tag);
             $apprenticeTags[$key] = $tag;
         }
         $data['apprenticeTags'] = $apprenticeTags;
         $mentorTags = $data['mentorTags'];
         unset($data['mentorTags']);
         foreach ($mentorTags as $key => $tag) {
             $tag = $this->termHydrator->extract($tag);
             $mentorTags[$key] = $tag;
         }
         $data['mentorTags'] = $mentorTags;
     }
     if ($data['timeCreated'] instanceof \DateTime) {
         $data['timeCreated'] = $data['timeCreated']->format(\DateTime::ISO8601);
     }
     if ($data['timezone'] instanceof \DateTimeZone) {
         $data['timezone'] = $data['timezone']->getName();
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * Makes sure that the setters and getters work properly
  *
  * @author Chris Tankersley <*****@*****.**>
  * @since 2015-04-28
  */
 public function testSettersAndGetters()
 {
     $testData = ['email' => '*****@*****.**', 'githubUid' => '1234', 'id' => 1, 'name' => 'Mr. McTest', 'roles' => ['ROLE_USER'], 'timeCreated' => new \DateTime(), 'timezone' => new \DateTimeZone("Europe/London"), 'enabled' => true, 'isMentee' => true, 'isMentor' => false, 'sendNotifications' => true, 'profile' => 'I am interested in learning about PHP.'];
     $user = new User();
     $user->setEmail($testData['email']);
     $user->setGithubUid($testData['githubUid']);
     $user->setId($testData['id']);
     $user->setName($testData['name']);
     $user->setRoles($testData['roles']);
     $user->setTimeCreated($testData['timeCreated']);
     $user->setTimezone($testData['timezone']);
     $user->setIsEnabled($testData['enabled']);
     $user->setIsMentee($testData['isMentee']);
     $user->setIsMentor($testData['isMentor']);
     $user->setSendNotifications($testData['sendNotifications']);
     $user->setProfile($testData['profile']);
     $this->assertEquals($testData['email'], $user->getEmail());
     $this->assertEquals($testData['githubUid'], $user->getGithubUid());
     $this->assertEquals($testData['id'], $user->getId());
     $this->assertEquals($testData['name'], $user->getName());
     $this->assertEquals($testData['roles'], $user->getRoles());
     $this->assertEquals($testData['timeCreated'], $user->getTimeCreated());
     $this->assertEquals($testData['enabled'], $user->isEnabled());
     $this->assertEquals($testData['isMentee'], $user->isMentee());
     $this->assertEquals($testData['isMentor'], $user->isMentor());
     $this->assertEquals($testData['sendNotifications'], $user->hasSendNotifications());
     $this->assertEquals($testData['profile'], $user->getProfile());
     $this->assertEquals($testData['timezone'], $user->getTimezone());
 }
Esempio n. 3
0
 /**
  * Makes sure that the setters and getters work properly
  *
  * @author Chris Tankersley <*****@*****.**>
  * @since 2015-04-28
  */
 public function testSettersAndGetters()
 {
     $testData = ['email' => '*****@*****.**', 'githubUid' => '1234', 'id' => 1, 'name' => 'Mr. McTest', 'roles' => ['ROLE_USER'], 'timeCreated' => new \DateTime(), 'enabled' => true, 'isMentee' => true, 'isMentor' => false];
     $user = new User();
     $user->setEmail($testData['email']);
     $user->setGithubUid($testData['githubUid']);
     $user->setId($testData['id']);
     $user->setName($testData['name']);
     $user->setRoles($testData['roles']);
     $user->setTimeCreated($testData['timeCreated']);
     $user->setIsEnabled($testData['enabled']);
     $user->setIsMentee($testData['isMentee']);
     $user->setIsMentor($testData['isMentor']);
     $this->assertEquals($testData['email'], $user->getEmail());
     $this->assertEquals($testData['githubUid'], $user->getGithubUid());
     $this->assertEquals($testData['id'], $user->getId());
     $this->assertEquals($testData['name'], $user->getName());
     $this->assertEquals($testData['roles'], $user->getRoles());
     $this->assertEquals($testData['timeCreated'], $user->getTimeCreated());
     $this->assertEquals($testData['enabled'], $user->isEnabled());
     $this->assertEquals($testData['isMentee'], $user->isMentee());
     $this->assertEquals($testData['isMentor'], $user->isMentor());
 }
Esempio n. 4
0
 protected function sendEmail(User $to, $subject, $template, $vars)
 {
     $body = $this->twig->render($template, array_merge(['to_name' => $to->getName(), 'to_email' => $to->getEmail()], $vars));
     $message = \Swift_Message::newInstance()->setSubject($subject)->addTo($to->getEmail())->addFrom($this->getDefaultFromEmail())->setBody($body);
     $this->mailer->send($message);
 }