/**
  * Creates a user by the new user entity
  *
  * @param User $user
  *
  * @return SimpleUserOverview
  */
 public static function fromAggregateRootDetails(User $user)
 {
     $credentials = $user->getCredentials();
     $identifier = $user->getId();
     $profileData = $user->getSimpleProfile();
     return new self($identifier, $credentials->getUsername(), $profileData->getEmail(), $profileData->getLocale());
 }
 /**
  * {@inheritdoc}
  */
 public function add(User $user)
 {
     $manager = $this->getEntityManager();
     $roleRepository = $this->getEntityManager()->getRepository('SEN_User:Role');
     $roles = array_map(function (Role $role) use($roleRepository) {
         return $roleRepository->findOneBy(['name' => (string) $role]);
     }, $user->getRoles());
     $userCopy = new User($user->getCredentials(), $user->getSimpleProfile(), $user->getFollowing(), $roles, $user->getActivation());
     $manager->persist($userCopy);
     $manager->flush();
     $created = $this->findOneByName($user->getCredentials()->getUsername());
     return $created;
 }
Ejemplo n.º 3
0
 public function testUpdateLastAction()
 {
     $user = new User(new Credentials('Ma27', 'test-pwd'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [], []);
     $now = new \DateTime();
     $user->updateLastAction($now);
     $this->assertSame($now, $user->getSimpleProfile()->getLastAction());
 }
 /**
  * Creates a security user from the actual symfony user
  *
  * @param User $user
  *
  * @return SecurityUser
  */
 private function toSecurityUser(User $user)
 {
     return new SecurityUser($user->getCredentials()->getUsername(), $user->getCredentials()->getPassword()->getHash(), $this->toSecurityRole($user->getRoles()), $user->getSimpleProfile()->isLocked());
 }