本文整理汇总了PHP中AppBundle\Entity\User::setPhone方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPhone方法的具体用法?PHP User::setPhone怎么用?PHP User::setPhone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setPhone方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
/**
* @Route("/admin-login", name="admin-login")
* @Template()
*/
public function loginAction()
{
// создание пользователя
$manager = $this->getDoctrine()->getManager();
$user = new User();
$user->setUsername('admin');
$user->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
$password = $encoder->encodePassword('admin', $user->getSalt());
$user->setPassword($password);
$user->setRoles('ROLE_OPERATOR');
$user->setLastName('admin');
$user->setFirstName('admin');
$user->setSurName('admin');
$user->setPhone('+79161111111');
//
$manager->persist($user);
$manager->flush($user);
if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
$pages = $this->getDoctrine()->getRepository('AppBundle:Page')->findAll();
return array('error' => $error, 'pages' => $pages);
}
示例2: addUserAction
/**
* @Route("/addUser/{uname}/{pswd}/{email}/{age}/{pic}/{phone}/{status}/{credit}")
*/
public function addUserAction($uname, $pswd, $email, $age, $pic, $phone, $status, $credit)
{
$response = new JsonResponse();
$res = $this->uniqAction($uname, $email, $phone, $credit);
if (empty($res)) {
$date = new \DateTime($age);
//$date->format('Y-m-d');
$user = new User();
$user->setName($uname);
$user->setNickName($uname);
$user->setPassword($pswd);
$user->setEmail($email);
$user->setBirthday($date);
$user->setPicpath($pic);
$user->setPhone($phone);
$user->setStatus($status);
$user->setCredit($credit);
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
//print_r($user);
$response->setData(array('response' => array('profile' => array(array("valid" => true)))));
} else {
$response->setData(array('response' => array('profile' => array($res))));
}
return $response;
}
示例3: 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;
}
示例4: registrationAction
/**
* @Route("/registration/{TrainingId}", name="registration")
*/
public function registrationAction(Request $request, $TrainingId)
{
$returnData = array();
$em = $this->getDoctrine()->getManager();
$repositoryUserTraining = $this->getDoctrine()->getRepository('AppBundle:UserTraining');
$returnData['TrainingUserCount'] = 0;
$returnData['TrainingUserCount'] = $repositoryUserTraining->getUserCount()[0]['TrainingUserCount'];
$data = $request->request->all();
if (isset($data["Patvirtinti"])) {
$returnData = $this->verificationRegistration($data, $returnData);
if ($returnData["request"]) {
$user = new User();
$user->setName($data['userName']);
$user->setSurname($data['userSurname']);
$user->setEmail($data['userEmail']);
$user->setPhone($data['userPhone']);
$user->setWorker(false);
$em->persist($user);
$em->flush();
$this->get('session')->set('UserId', $user->getId());
$this->get('session')->set('UserName', $user->getName());
$this->get('session')->set('UserSurname', $user->getSurname());
$this->get('session')->set('worker', false);
$repositoryUserTraining->setUserInTraining($user->getId(), $TrainingId);
}
}
if (!is_null($this->get('session')->get('UserId'))) {
$repositoryUserTraining->setUserInTraining($this->get('session')->get('UserId'), $TrainingId);
}
$repository = $this->getDoctrine()->getRepository('AppBundle:Training');
$training = $repository->findById($TrainingId);
if (!$training) {
throw $this->createNotFoundException('');
}
$returnData['TrainingName'] = $training[0]->getTrainingName();
$returnData['TrainingUserCountMax'] = $training[0]->getTrainingUserCount();
$returnData['TrainingId'] = $training[0]->getId();
return $this->render('default/registration.html.twig', ['data' => $returnData]);
}
示例5: createData
//.........这里部分代码省略.........
$em->flush();
$jeleniaGoraCity = new City();
$jeleniaGoraCity->setProvince($dolnoslaskieProvince);
$jeleniaGoraCity->setActive(1);
$jeleniaGoraCity->setName('Jelenia Góra');
$em = $this->getDoctrine()->getManager();
$em->persist($jeleniaGoraCity);
$em->flush();
$zmigrodCity = new City();
$zmigrodCity->setProvince($dolnoslaskieProvince);
$zmigrodCity->setActive(1);
$zmigrodCity->setName('Żmigród');
$em = $this->getDoctrine()->getManager();
$em->persist($zmigrodCity);
$em->flush();
$sobotkaCity = new City();
$sobotkaCity->setProvince($dolnoslaskieProvince);
$sobotkaCity->setActive(1);
$sobotkaCity->setName('Sobótka');
$em = $this->getDoctrine()->getManager();
$em->persist($sobotkaCity);
$em->flush();
$user = new User();
$user->setProvince($dolnoslaskieProvince);
$user->setCity($wroclawCity);
$user->setActive(1);
$user->setName('Robert');
$user->setSurname('Rybiański');
$user->setLogin('login');
$user->setPassword(md5('password'));
$user->setKey(md5(date('Y-m-d H:i:s') . 'password'));
$user->setEmail('imie@nazwisko.pl');
$user->setUrl('http://www.domena.pl/');
$user->setPhone('226666666');
$user->setStreet('Ulica 6');
$user->setPostcode('66-666');
$user->setDescription('Pierwszy użytkownik...');
$user->setCommentNumber(13);
$user->setCommentPositive7Days(2);
$user->setCommentNeutral7Days(1);
$user->setCommentNegative7Days(0);
$user->setCommentPositive30Days(3);
$user->setCommentNeutral30Days(1);
$user->setCommentNegative30Days(1);
$user->setCommentPositiveAllDays(10);
$user->setCommentNeutralAllDays(2);
$user->setCommentNegativeAllDays(1);
$user->setCommentDate($dateTime = new \DateTime('2016-03-14 16:31:09'));
$user->setIpAdded('127.0.0.1');
$user->setDateAdded($dateTime);
$user->setIpUpdated('127.0.0.1');
$user->setDateUpdated($dateTime);
$user->setIpLoged('127.0.0.1');
$user->setDateLoged($dateTime);
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$firm = new Firm();
$firm->setUser($user);
$firm->setProvince($dolnoslaskieProvince);
$firm->setCity($wroclawCity);
$firm->setActive(1);
$firm->setVisible(1);
$firm->setOrder(1);
$firm->setName('Firma Pierwsza');
$firm->setEmail('nazwa@firma.pl');
示例6: 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');
//.........这里部分代码省略.........
示例7: setPhone
/**
* {@inheritDoc}
*/
public function setPhone($phone)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setPhone', array($phone));
return parent::setPhone($phone);
}
示例8: registerAction
/**
* @Route("/rejestracja")
*/
public function registerAction(Request $request)
{
$config = new Config();
$session = $request->getSession();
$cookieLogin = new CookieLogin($em = $this->getDoctrine()->getManager());
$cookieLogin->setCookieLogin($session);
$quickForm = new QuickForm($this, $request);
$email = new Email($this);
$messageString = '';
$messageClass = 'bad';
$registerForm = new RegisterForm();
$form = $this->createForm(RegisterFormType::class, $registerForm);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$validator = $this->get('validator');
$errors = $validator->validate($registerForm);
if (count($errors) > 0) {
foreach ($errors as $error) {
$messageString .= $error->getMessage() . '<br />';
}
} else {
if ($this->getDoctrine()->getRepository('AppBundle:User')->isUserLogin($registerForm->getLogin())) {
$messageString .= 'Konto o podanym loginie już istnieje.<br />';
} else {
$user = new User();
$user->setProvince(NULL);
$user->setCity(NULL);
$user->setActive(0);
$user->setName($registerForm->getName());
$user->setSurname($registerForm->getSurname());
$user->setLogin($registerForm->getLogin());
$user->setPassword(md5($registerForm->getPassword()));
$user->setKey(md5(date('Y-m-d H:i:s') . $registerForm->getPassword()));
$user->setEmail($registerForm->getEmail());
$user->setUrl('');
$user->setPhone('');
$user->setStreet('');
$user->setPostcode('');
$user->setDescription('');
$user->setCommentNumber(0);
$user->setCommentPositive7Days(0);
$user->setCommentNeutral7Days(0);
$user->setCommentNegative7Days(0);
$user->setCommentPositive30Days(0);
$user->setCommentNeutral30Days(0);
$user->setCommentNegative30Days(0);
$user->setCommentPositiveAllDays(0);
$user->setCommentNeutralAllDays(0);
$user->setCommentNegativeAllDays(0);
$user->setCommentDate($dateTime = new \DateTime('now'));
$user->setIpAdded($config->getRemoteAddress());
$user->setDateAdded($dateTime);
$user->setIpUpdated('');
$user->setDateUpdated(new \DateTime('1970-01-01 00:00:00'));
$user->setIpLoged('');
$user->setDateLoged(new \DateTime('1970-01-01 00:00:00'));
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$messageString .= 'Konto użytkownika zostało utworzone.<br />';
$messageClass = 'ok';
if ($this->sendActivationEmail($config, $email, $registerForm, $user)) {
$messageString .= 'Sprawdź pocztę w celu aktywacji konta.<br />';
} else {
$messageString .= "Wysłanie e-mail'a aktywacyjnego nie powiodło się.<br />";
$messageClass = 'bad';
}
unset($registerForm);
unset($form);
$registerForm = new RegisterForm();
$form = $this->createForm(RegisterFormType::class, $registerForm);
}
}
}
$menu = new Menu($em, 1, 0);
return $this->render('register/register.html.twig', array('session' => $session->get('user'), 'quickForm' => $quickForm->createView(), 'form' => $form->createView(), 'messageString' => $messageString, 'messageClass' => $messageClass, 'activeCategory' => 1, 'activeProvince' => 0, 'activeCity' => 0, 'categories' => $menu->getCategories(), 'places' => $menu->getPlaces(), 'isProvince' => $menu->isProvince()));
}
示例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]);
}
}
示例10: createUserAction
/**
* @Route("/api/createUser", name="createUser"), defaults={"_format"="xml"}, name="_createUser")
*/
public function createUserAction(Request $request)
{
try {
$verificationCode = $request->get('verificationcode', '');
if ($verificationCode == '') {
$oOperation = new Operation();
$oOperation->setBSucceeded(false);
$oOperation->setICode(409);
$oOperation->setSMessage("Phone validation failed");
return $this->xmlResponse($oOperation, SerializationContext::create()->setGroups(array('Error')), 409);
}
$username = $request->get('username', null);
$phone = $request->get('phone', null);
$deviceId = $request->get('deviceid', null);
$contactsPhones = $request->get('contactsphones', null);
$em = $this->getDoctrine()->getManager();
//Get current device
$deviceRepository = $em->getRepository('AppBundle:UserDevice');
$device = $deviceRepository->findOneBy(array('deviceId' => $deviceId));
if (!isset($device)) {
$oOperation = new Operation();
$oOperation->setBSucceeded(false);
$oOperation->setICode(409);
$oOperation->setSMessage("Device not found");
return $this->xmlResponse($oOperation, SerializationContext::create()->setGroups(array('Error')), 409);
}
$userRepository = $em->getRepository('AppBundle:User');
$user = $userRepository->findOneBy(array('phone' => $phone));
if (!isset($user)) {
$user = new User();
$user->setCdate((new DateTime())->setTimezone(new \DateTimeZone('UTC')));
$user->setTKey(sha1(date_format(new DateTime(), 'Y-m-d H:i:s') . $phone));
$user->setAvatar(self::DEFAULT_AVATAR_URL);
}
/** TODO ensure normalized Phone */
$user->setPhone($phone);
$user->setUsername($username);
//If we have a registered User append his already existing contacts
//Store the new contact list $updatedContactsPhones
$contactsPhonesArray = explode(',', $contactsPhones);
if (empty($user->getContactsphones())) {
$user->setContactsphones(json_encode(array_values($contactsPhonesArray)));
}
if (isset($device) && isset($user)) {
$contactsPhonesArray = $this->appendUserContacts($user, $contactsPhonesArray);
}
$updatedContactsPhones = json_encode(array_values($contactsPhonesArray));
//Get lastest contacts Users and store their ids via $contactsUserIds
$contactsUserIds = array();
if (isset($contactsPhones)) {
$contactsUsers = $userRepository->findBy(array('phone' => $contactsPhonesArray));
foreach ($contactsUsers as $contactsUser) {
$contactsUserIds[] = $contactsUser->getId();
if (!$user->getMyContacts()->Contains($contactsUser)) {
$user->addMyContact($contactsUser);
}
}
}
$contactsUserIds = json_encode($contactsUserIds);
$user->setConnections($contactsUserIds);
$user->setContactsPhones($updatedContactsPhones);
$user->setLastUpdate((new DateTime())->setTimezone(new \DateTimeZone('UTC')));
$em->persist($user);
$em->flush();
//Update the device
$device->setUser($user);
$device->setIsUserRegistered(true);
$em->persist($device);
$em->flush();
return $this->xmlResponse($device, SerializationContext::create()->enableMaxDepthChecks()->setGroups(array('Device')));
} catch (Exception $ex) {
$oOperation = new Operation();
$oOperation->setBSucceeded(false);
$oOperation->setICode(409);
$oOperation->setSMessage("Phone validation failed");
$oError = new Error();
$oError->setICode($ex->getCode());
$oError->setSMessage($ex->getMessage());
$oOperation->addError($oError);
return $this->xmlResponse($oOperation, SerializationContext::create()->setGroups(array('Error')), 409);
}
}
示例11: registerAction
/**
* @Route("/register", name="register")
* @Template()
*/
public function registerAction(Request $request)
{
if ($request->getMethod() == 'POST') {
$manager = $this->getDoctrine()->getManager();
$user = new User();
$user->setUsername($request->request->get('username'));
$user->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
$password = $encoder->encodePassword($request->request->get('password'), $user->getSalt());
$user->setPassword($password);
$user->setRoles('ROLE_UNCONFIRMED');
$user->setLastName($request->request->get('lastName'));
$user->setFirstName($request->request->get('firstName'));
$user->setSurName('');
$user->setPhone($request->request->get('phone'));
$user->setCompany($request->request->get('companyTitle'));
$manager->persist($user);
$manager->flush($user);
$manager->refresh($user);
$session = new Session();
$session->getFlashBag()->add('success', 'Ваша заявка принята. Пожалуйста, ожидайте подтверждения регистрации на указанный электронный адрес');
@$this->get('email.service')->send(array($user->getUsername()), array('AppBundle:Email:registerNotifyUser.html.twig'), 'Сообщение от navigator mediaFirst');
@$this->get('email.service')->send(array('tulupov.m@gmail.com', 'ryabova.t@mediafirst.ru', 'kravtsova.m@mediafirst.ru'), array('AppBundle:Email:registerNotify.html.twig'), 'Сообщение от navigator mediaFirst');
return $this->redirect($this->generateUrl('homepage'));
}
return array();
}
示例12: testSetPhone
public function testSetPhone()
{
// new entity
$user = new User();
// Use the setPhone method
$user->setPhone("12312312");
// Assert the result
$this->assertEquals("12312312", $user->getPhone());
}