Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $fixturesPath = realpath(dirname(__FILE__) . '/../fixtures');
     $fixtures = Yaml::parse(file_get_contents($fixturesPath . '/user.yml'));
     foreach ($fixtures['users'] as $user_key => $user_values) {
         $entity = new User();
         $entity->setFirstName(ucwords($user_values['first_name']));
         $entity->setLastName(ucwords($user_values['last_name']));
         $entity->setEmail($user_values['email']);
         $entity->setUserType($user_values['user_type']);
         $entity->setGender($user_values['gender']);
         $entity->setCreatedAt(new \DateTime('now'));
         $entity->setUpdatedAt(new \DateTime('now'));
         $entity->setPassword(md5($user_values['password']));
         $manager->persist($entity);
         $manager->flush();
     }
 }
Ejemplo n.º 2
0
 public function registration($request_array)
 {
     $email = $request_array['email'];
     $password = $request_array['password'];
     $gender = $request_array['gender'];
     $zipcode = $request_array['zipcode'];
     if ($this->isDuplicateEmail(Null, $email)) {
         return false;
     } else {
         $user = new User();
         $user->setCreatedAt(new \DateTime('now'));
         $user->setUpdatedAt(new \DateTime('now'));
         //$factory = $this->get('security.encoder_factory');
         //$encoder = $factory->getEncoder($user);
         //  $password = $encoder->encodePassword($password, $user->getSalt());
         $user->setPassword($password);
         $user->setEmail($email);
         $user->setGender($gender);
         $user->setZipcode($zipcode);
         $this->saveUser($user);
         $userinfo = array();
         $userinfo['email'] = $user->getEmail();
         $userinfo['gender'] = $user->getGender();
         $userinfo['zipcode'] = $user->getZipcode();
         return $userinfo;
     }
 }