Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('nglaser');
     $user->setEmail('*****@*****.**');
     $user->setRoles(array("ROLE_USER"));
     $user->setIsActive(true);
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('password', $user->getSalt()));
     $prop1 = new UserProperties();
     $prop1->setName('facebook');
     $prop1->setValue('noah.glaser.75');
     $user->addUserproperty($prop1);
     $prop2 = new UserProperties();
     $prop2->setName('twitter');
     $prop2->setValue('thesqlman');
     $user->addUserproperty($prop2);
     $manager->persist($user);
     $manager->flush();
 }
 public function updateUser(DBUser $userdb, APIUser $userAPI)
 {
     if (!empty($userAPI->getUsername())) {
         $userdb->setUsername($userAPI->getUsername());
     }
     if (!empty($userAPI->getEmail())) {
         $userdb->setEmail($userAPI->getEmail());
     }
     foreach ($userdb->getUserproperties() as $dbProp) {
         foreach ($userAPI->getProperties() as $userProp) {
             if ($dbProp->getId() == $userProp->getId()) {
                 $dbProp->setValue($userProp->getValue());
             }
         }
     }
     $this->em->persist($userdb);
     $this->em->flush();
     return $this->getSingleUser($userdb->getId());
 }