当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setGender方法代码示例

本文整理汇总了PHP中AppBundle\Entity\User::setGender方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setGender方法的具体用法?PHP User::setGender怎么用?PHP User::setGender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::setGender方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: injectUser

 protected function injectUser()
 {
     $this->user = new User();
     //$admin = 'tester'; // MWAHAHAHA
     //$departmentId = 5; // UiB
     $role = $this->em->getRepository('AppBundle:Role')->findOneByRole('ROLE_USER');
     $this->user->addRole($role);
     $this->user->setGender(1);
     $this->user->setFirstName("Shi");
     $this->user->setLastName("LaLong");
     $emd = $this->em->getRepository('AppBundle:FieldOfStudy')->find(40);
     // Tuple "Andre" from UiB, id 40 for fos
     $this->user->setFieldOfStudy($emd);
     $this->user->setUserName("shiluib");
     // Weird typo?
     $this->user->setEmail("shiluib@student.uib.no");
     $this->user->setPhone("47661674");
     $this->user->setPicturePath("images/defaultProfile.png");
     $this->user->setPassword("pimwrneil");
     $createNewUserCode = bin2hex(openssl_random_pseudo_bytes(16));
     $hashedNewUserCode = hash('sha512', $createNewUserCode, false);
     $this->user->setNewUserCode($hashedNewUserCode);
     // Persist the user
     $this->user->setIsActive(1);
     $this->em->persist($this->user);
     $this->em->flush();
     return $this;
 }
开发者ID:vegardbb,项目名称:webpage,代码行数:28,代码来源:UserRepositoryFunctionalTest.php

示例2: testSetGender

 public function testSetGender()
 {
     // new entity
     $user = new User();
     // Use the setGender method
     $user->setGender("0");
     // Assert the result
     $this->assertEquals("0", $user->getGender());
 }
开发者ID:vegardbb,项目名称:webpage,代码行数:9,代码来源:UserEntityUnitTest.php

示例3: load

 public function load(ObjectManager $manager)
 {
     $u1 = new User();
     $u1->setUsername('admin');
     $u1->setGender(1);
     $u1->setEmail("test@test.com");
     $u1->setCreationDate(new \DateTime('now'));
     $u1->setModificationDate(new \DateTime('now'));
     $manager->persist($u1);
     $manager->flush();
 }
开发者ID:fengxw,项目名称:dirty,代码行数:11,代码来源:LoadUserData.php

示例4: getUser

 public function getUser($authorizationCode, UserProviderInterface $userProvider)
 {
     $provider = $this->getFacebookOAuthProvider();
     try {
         // the credentials are really the access token
         $accessToken = $provider->getAccessToken('authorization_code', ['code' => $authorizationCode]);
     } catch (IdentityProviderException $ex) {
         $response = $e->getResponseBody();
         $errorCode = $response['error']['code'];
         $message = $response['error']['message'];
         //var_dump($response);
         //TODO throw a custom error to handle ???
     }
     $fbUser = $provider->getResourceOwner($accessToken);
     $email = $fbUser->getEmail();
     $facebookId = $fbUser->getId();
     $gender = $fbUser->getGender();
     $firstname = $fbUser->getFirstName();
     $lastname = $fbUser->getLastname();
     $locale = $fbUser->getLocale();
     $name = $fbUser->getName();
     $em = $this->container->get('doctrine')->getManager();
     $user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $email]);
     //If there is no user, we need to create one
     if (!$user) {
         $user = new User();
         $user->setUsername($email);
         $user->setEmail($email);
         $user->setGender($gender);
         $user->setFirstname($firstname);
         $user->setLastname($lastname);
         $user->setLocale($locale);
         $user->setFacebookName($name);
         //Set to unencoded password.
         //Since passwords are encode when checked, users should not be able to login using it
         $user->setPassword('FACEBOOK LOGIN');
         //Make sure that a user has at least the role of ROLE_USER when created
         $roles = $user->getRoles();
         $user->setRoles($roles);
     }
     $user->setLastLogin(new \DateTime());
     $user->setFacebookId($facebookId);
     $em->persist($user);
     $em->flush();
     return $user;
 }
开发者ID:onlinespaces,项目名称:symfony-guard-project,代码行数:46,代码来源:FacebookAuthenticator.php

示例5: load

 public function load(ObjectManager $manager)
 {
     $u1 = new User();
     $u1->setUsername('admin');
     $u1->setGender(1);
     $u1->setEmail("test@test.com");
     $u1->setCreationDate(new \DateTime('now'));
     $u1->setModificationDate(new \DateTime('now'));
     $t1 = new Topic();
     $t1->setTitle('first topic');
     $t1->setAnthorId(1);
     $t1->setAgree(1);
     $t1->setDisagree(0);
     $t1->setContent('long long long string');
     $t1->setModificationDate(new \DateTime('now'));
     $t1->setCreationDate(new \DateTime('now'));
     $manager->persist($u1);
     $manager->persist($t1);
     $manager->flush();
 }
开发者ID:fengxw,项目名称:dirty,代码行数:20,代码来源:LoadTopicData.php

示例6: installUsers

 public function installUsers()
 {
     $maleNames = array("Maaiz Rahim", "Aayid Akram", "Salaah Fadel", "Raadi Zaman", "Yahya Morad", "Sirajuddeen Sultan", "Saleem Yusuf", "Salaah Hoque", "Maaiz Jafari", "Mushtaaq Sultan", "Anwar Shahidi", "Awni Ameen", "Jawaad Barakat", "Mamoon Bari", "Hibbaan Baten", "Abdul Baasid Ali", "Abdul Ghafoor Kazemi", "Bishr Shehata", "Mujahid Rahaim", "Badraan Abdullah", "Anwar Shahidi", "Awni Ameen", "Jawaad Barakat", "Mamoon Bari", "Hibbaan Baten", "Abdul Baasid Ali", "Abdul Ghafoor Kazemi", "Bishr Shehata", "Mujahid Rahaim", "Badraan Abdullah", "Shuraih Daoud", "Aiman Sabet", "Sad Kamara", "Munsif Hamidi", "Usaama Hamed", "Abdur Raqeeb Can", "Muaaid Haider", "Arkaan Afzal", "Ashqar Hashem", "Ammaar Rasul");
     $femaleNames = array("Nahla Fahmy", "Umaima Rayes", "Zuhra Jabbour", "Laaiqa Naderi", "Sitaara Hashmi", "Awda Ozer", "Sulama Afzal", "Sanad Mahmood", "Maimoona Amara", "Nuha Neman", "Mahdeeya Khan", "Tareefa Salman", "Rumaana Hadi", "Qaaida Tariq", "Wasmaaa Dada", "Kinaana Barakat", "Hadiyya Mahdi", "Majeeda Mohammed", "Hameeda Younan", "Kawkab Vaziri", "Labeeba Hamad", "Tahaani Farhat", "Zumruda Hussain", "Nadheera Koroma", "Suhaa Naim", "Reema Shah", "Saajida Samaan", "Ameera Jamail", "Almaasa Adel", "Shamaail Fahs", "Qamraaa Sadri", "Nuzha Ghazal", "Tamanna Azimi", "Fareeda Kanan", "Hamaama Gaber", "Majeeda Hamidi", "Nabeeha Suleiman", "Manaara Khalil", "Saaliha Abraham", "Faraah Hammad");
     for ($i = 0; $i < 100; $i++) {
         $user = new User();
         if ($i % 2 == 0) {
             $male = "male";
             $name = $maleNames[rand(0, 6)];
             $img = $this->getImage("men");
         } else {
             $male = "female";
             $names = $femaleNames[rand(0, 6)];
             $img = $this->getImage("women");
         }
         $username = str_replace(' ', '', $name);
         $mail = $username . "@gmail.com";
         $num = "658806711";
         $user->setUsername($username . rand(1, 50000));
         $user->setFullName($name);
         $user->setEmail($mail);
         $user->setNumber($num);
         $days = rand(10, 40) * 365 + rand(1, 400);
         $str = $days . " days ago";
         $user->setDob(new \DateTime($str));
         $user->setPassword("pass");
         $user->setGender($male);
         $user->setPicture($img);
         $em = $this->getDoctrine()->getManager();
         $factory = $this->get('security.encoder_factory');
         $encoder = $factory->getEncoder($user);
         $password = $encoder->encodePassword($user->getPassword(), $user->getSalt());
         $user->setPassword($password);
         $em->persist($user);
         $em->flush();
     }
 }
开发者ID:RAFnut,项目名称:Competition-REFU.G,代码行数:37,代码来源:MakeUsersController.php

示例7: load

 public function load(ObjectManager $manager)
 {
     $user1 = new User();
     $user1->setIsActive('1');
     $user1->setEmail('petter@stud.ntnu.no');
     $user1->setFirstName('Petter');
     $user1->setLastName('Johansen');
     $user1->setGender('0');
     $user1->setPhone('95347865');
     $user1->setUserName('petjo');
     $user1->setPassword('1234');
     $user1->addRole($this->getReference('role-4'));
     $user1->setFieldOfStudy($this->getReference('fos-1'));
     $user1->setPicturePath('images/defaultProfile.png');
     $manager->persist($user1);
     $user2 = new User();
     $user2->setIsActive('1');
     $user2->setEmail('ida@stud.ntnu.no');
     $user2->setFirstName('Ida');
     $user2->setLastName('Andreassen');
     $user2->setGender('1');
     $user2->setPhone('95267841');
     $user2->setUserName('idaan');
     $user2->setPassword('1234');
     $user2->addRole($this->getReference('role-1'));
     $user2->setFieldOfStudy($this->getReference('fos-2'));
     $user2->setPicturePath('images/defaultProfile.png');
     $manager->persist($user2);
     $user3 = new User();
     $user3->setIsActive('1');
     $user3->setEmail('kristoffer@stud.ntnu.no');
     $user3->setFirstName('Kristoffer');
     $user3->setLastName('Bø');
     $user3->setGender('0');
     $user3->setPhone('95148725');
     $user3->setUserName('kribo');
     $user3->setPassword('1234');
     $user3->addRole($this->getReference('role-1'));
     $user3->setFieldOfStudy($this->getReference('fos-3'));
     $user3->setPicturePath('images/defaultProfile.png');
     $manager->persist($user3);
     $user4 = new User();
     $user4->setIsActive('1');
     $user4->setEmail('alm@mail.com');
     $user4->setFirstName('Thomas');
     $user4->setLastName('Alm');
     $user4->setGender('0');
     $user4->setPhone('12312312');
     $user4->setUserName('thomas');
     $user4->setPassword('123');
     $user4->addRole($this->getReference('role-1'));
     $user4->setFieldOfStudy($this->getReference('fos-1'));
     $user4->setPicturePath('images/defaultProfile.png');
     $manager->persist($user4);
     $user5 = new User();
     $user5->setIsActive('1');
     $user5->setEmail('a@b.c');
     $user5->setFirstName('Reidun');
     $user5->setLastName('Persdatter Ødegaard');
     $user5->setGender('1');
     $user5->setPhone('92269548');
     $user5->setUserName('reidun');
     $user5->setPassword('123');
     $user5->addRole($this->getReference('role-4'));
     $user5->setFieldOfStudy($this->getReference('fos-1'));
     $user5->setPicturePath('images/defaultProfile.png');
     $manager->persist($user5);
     $user6 = new User();
     $user6->setIsActive('1');
     $user6->setEmail('b@b.c');
     $user6->setFirstName('Siri');
     $user6->setLastName('Brenna Eskeland');
     $user6->setGender('1');
     $user6->setPhone('99540025');
     $user6->setUserName('siri');
     $user6->setPassword('123');
     $user6->addRole($this->getReference('role-4'));
     $user6->setFieldOfStudy($this->getReference('fos-1'));
     $user6->setPicturePath('images/defaultProfile.png');
     $manager->persist($user6);
     $user7 = new User();
     $user7->setIsActive('1');
     $user7->setEmail('c@b.c');
     $user7->setFirstName('Eirik');
     $user7->setLastName('Myrvoll-Nilsen');
     $user7->setGender('0');
     $user7->setPhone('93093824');
     $user7->setUserName('eirik');
     $user7->setPassword('123');
     $user7->addRole($this->getReference('role-2'));
     $user7->setFieldOfStudy($this->getReference('fos-1'));
     $user7->setPicturePath('images/defaultProfile.png');
     $manager->persist($user7);
     $user8 = new User();
     $user8->setIsActive('1');
     $user8->setEmail('d@b.c');
     $user8->setFirstName('Ruben');
     $user8->setLastName('Ravnå');
     $user8->setGender('0');
     $user8->setPhone('98059155');
//.........这里部分代码省略.........
开发者ID:vegardbb,项目名称:webpage,代码行数:101,代码来源:LoadUserData.php

示例8: loadUsers

 /**
  * @param ObjectManager $manager
  */
 protected function loadUsers(ObjectManager $manager)
 {
     $user = new User();
     $user->setEmail('learner@example.com');
     $user->setFirstName('Kalle');
     $user->setLastName('Anka');
     $user->setEnabled(true);
     $user->addRole('ROLE_COMPLETE_USER');
     $user->setWantToLearn(true);
     $user->setAge(35);
     $user->setAbout('Sportintresserad man med 3 barn');
     $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]);
     $user->setFrom('SY');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/1.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-learner', $user);
     $user = new User();
     $user->setEmail('fluentspeaker@example.com');
     $user->setFirstName('Kal p');
     $user->setLastName('Dal');
     $user->setEnabled(true);
     $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']);
     $user->setWantToLearn(false);
     $user->setAge(40);
     $user->setAbout('Sportintresserad lärare');
     $user->setCategories([$this->getReference('category-0'), $this->getReference('category-1')]);
     $user->setFrom('SE');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/2.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-fluentspeaker', $user);
     $user = new User();
     $user->setEmail('glenn@example.com');
     $user->setFirstName('Glenn');
     $user->setLastName('GBG');
     $user->setEnabled(true);
     $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']);
     $user->setWantToLearn(false);
     $user->setAge(20);
     $user->setAbout('Göteborgare');
     $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]);
     $user->setFrom('SE');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/3.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-glenn', $user);
     $user = new User();
     $user->setEmail('incomplete@example.com');
     $user->setEnabled(true);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
 }
开发者ID:EmmaHammar,项目名称:Kompisbyran,代码行数:62,代码来源:LoadData.php

示例9: createUnactivatedUserAction

 /**
  * Creates an unactivated user for the given application.
  * This method is intended to be called by an Ajax request.
  * TODO: FIll in description
  *
  * @param $id
  * @return JsonResponse
  */
 public function createUnactivatedUserAction($id)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $application = $em->getRepository('AppBundle:Application')->findApplicantById($id);
         $role = $em->getRepository('AppBundle:Role')->findOneByName(AdmissionAdminController::NEW_USER_ROLE);
         // Create the hash
         $createNewUserCode = bin2hex(openssl_random_pseudo_bytes(16));
         $hashedNewUserCode = hash('sha512', $createNewUserCode, false);
         // Copy information from the given application to a new user
         $user = new User();
         $user->setLastName($application->getLastName());
         $user->setFirstName($application->getFirstName());
         $user->setGender($application->getStatistic()->getGender());
         $user->setPhone($application->getPhone());
         $user->setFieldOfStudy($application->getStatistic()->getFieldOfStudy());
         $user->setEmail($application->getEmail());
         // Create Username from email, and make sure it's unique
         $new_username = explode("@", $application->getEmail())[0];
         $user_rep = $em->getRepository('AppBundle:User');
         $violator = $user_rep->findOneBy(array('user_name' => $new_username));
         $postfix = 0;
         while ($violator) {
             $postfix++;
             $violator = $user_rep->findOneBy(array('user_name' => $new_username . $postfix));
         }
         if ($postfix) {
             $new_username = $new_username . $postfix;
         }
         $user->setUserName($new_username);
         $user->setPassword($new_username);
         $user->setIsActive('0');
         $user->setNewUserCode($hashedNewUserCode);
         // Give the new user the default role
         $user->addRole($role);
         // Update the application
         $application->setUserCreated(true);
         // Update application statistic
         $application->getStatistic()->setAccepted(true);
         // Persist
         $em->persist($application);
         $em->persist($user);
         $em->flush();
         //Sends a email with the url for resetting the password
         //echo('127.0.0.1:8000/opprettbruker/'.$createNewUserCode.'');
         $this->sendNewUserEmail($createNewUserCode, $user->getEmail());
         return new JsonResponse(['success' => true]);
     } catch (\Exception $e) {
         // If it is a integrity violation constraint (i.e a user with the email already exists)
         if ($e->getPrevious()) {
             //If the error occurred when sending email, $e->getPrevious() will be null
             if ($e->getPrevious()->getCode() == 23000) {
                 $message = 'En bruker med denne E-posten eksisterer allerede.';
             }
         } else {
             $message = 'En feil oppstod. Kontakt IT ansvarlig.';
         }
         return new JsonResponse(['success' => false, 'cause' => $message]);
     }
 }
开发者ID:vegardbb,项目名称:webpage,代码行数:68,代码来源:AdmissionAdminController.php

示例10: update

 public function update(User $user, $firstname, $lastname, $email, $username, $password, $about, $picture, $location, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, $contactWebsite, $contactTwitter, $contactLinkedIn, $contactCertification, $contactGitHub, $contactStackOverflow)
 {
     if ($errors = $this->getErrors($firstname, $lastname, $email, $username, $password, $about, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, true, $password == '' ? false : true)) {
         throw new ServiceException($errors);
     }
     $user->setUsername($username);
     $user->setFirstname($firstname);
     $user->setLastname($lastname);
     $user->setEmail($email);
     $user->setAbout($about);
     $user->setLocation($location);
     $user->setLocationCityShort($locationCityShort);
     $user->setLocationCityLong($locationCityLong);
     $user->setLocationStateShort($locationStateShort);
     $user->setLocationStateLong($locationStateLong);
     $user->setLocationCountryShort($locationCountryShort);
     $user->setLocationCountryLong($locationCountryLong);
     $user->setGender($gender);
     $user->setCompany($company);
     $user->setIsAvailableToHiring($isAvailableToHiring);
     $user->setContactWebsite($contactWebsite);
     $user->setContactTwitter($contactTwitter);
     $user->setContactLinkedIn($contactLinkedIn);
     $user->setContactCertification($contactCertification);
     $user->setContactGitHub($contactGitHub);
     $user->setContactStackOverflow($contactStackOverflow);
     $user->setUpdatedAt(new \DateTime());
     if ($picture) {
         $user->setPicturePath($this->moveImageFromTmpToFolder($picture));
     }
     if ($password) {
         $user->setPassword(md5($password));
     }
     return $this->repository->create($user);
 }
开发者ID:matheusgontijo,项目名称:MageBrazuca,代码行数:35,代码来源:UserService.php


注:本文中的AppBundle\Entity\User::setGender方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。