本文整理汇总了PHP中AppBundle\Entity\User::setFirstname方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setFirstname方法的具体用法?PHP User::setFirstname怎么用?PHP User::setFirstname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setFirstname方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetFirstname
public function testSetFirstname()
{
// new entity
$user = new User();
// Use the setFirstname method
$user->setFirstname("olsen");
// Assert the result
$this->assertEquals("olsen", $user->getFirstname());
}
示例2: load
/**
* @param ObjectManager $em
*/
function load(ObjectManager $em)
{
$users = ['joda', 'luke'];
foreach ($users as $username) {
$user = new User();
$user->setFirstname(ucfirst($username));
$user->setUsername($username);
$passwd = $this->container->get('security.password_encoder')->encodePassword($user, 'secret');
$user->setPassword($passwd);
$em->persist($user);
}
$em->flush();
}
示例3: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$user = new User();
$user->setFirstname('Super');
$user->setLastname('Admin');
$user->setUsername('super_Admin');
$user->setEmailId('anil.chauhan@cuelogic.co.in');
$user->setPassword($this->container->get('security.password_encoder')->encodePassword($user, '123456'));
$user->setRole($manager->merge($this->getReference('role-super-admin')));
$user->setCreatedOn(new \DateTime());
$manager->persist($user);
$manager->flush();
$this->addReference('super_admin_user', $user);
}
示例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;
}
示例5: testProfileFormFailure
public function testProfileFormFailure()
{
$formData = array('username' => 'Kristof01', 'firstname' => 'Kristof', 'lastname' => 'Spaas');
$form = $this->factory->create(ProfileType::class);
// submit the data to the form directly
$form->submit($formData);
$user = new User();
$user->setUsername('Jan01');
$user->setFirstname('Jan');
$user->setLastname('Peeters');
$this->assertTrue($form->isSynchronized());
$this->assertNotEquals($user, $form->getData());
$view = $form->createView();
$children = $view->children;
foreach (array_keys($formData) as $key) {
$this->assertArrayHasKey($key, $children);
}
}
示例6: registerAction
/**
* @Route("/register", name="register")
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function registerAction(Request $request)
{
if ($request->isXmlHttpRequest()) {
$em = $this->getDoctrine()->getManager();
$user = new User();
$user->setFirstname($request->request->get('form-first-name'));
$user->setLastname($request->request->get('form-last-name'));
$user->setEmail($request->request->get('form-email'));
$user->setPlainPassword($request->request->get('form-password'));
$em->persist($user);
$em->flush();
$json = json_encode(['result' => 'Thank You for Registering.']);
$response = new Response($json);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
return $this->render(':account:register.html.twig');
}
示例7: load
/**
* @param ObjectManager $em
*/
public function load(ObjectManager $em)
{
if (!in_array($this->container->getParameter('kernel.environment'), ['dev'])) {
return;
// only for dev environment
}
$faker = Factory::create();
$users = ['joda' => ['ROLE_ADMIN'], 'luke' => ['ROLE_USER']];
foreach ($users as $username => $roles) {
$user = new User();
$user->setFirstname($faker->firstname);
$user->setLastname($faker->lastname);
$user->setEmail($username . '@datadog.lt');
$user->setRoles($roles);
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
$user->setPassword($encoder->encodePassword('S3cretpassword', $user->getSalt()));
$em->persist($user);
}
$em->flush();
}
示例8: userNamed
/**
* @Given /^(confirmed|unconfirmed) (user|admin) named "([^"]+)"$/
*/
function userNamed($status, $type, $name)
{
$names = explode(' ', $name);
list($firstname, $lastname) = $names;
$em = $this->get('em');
$user = new User();
if ('confirmed' === $status) {
$user->setFirstname($firstname);
$user->setLastname($lastname);
}
$user->setEmail(strtolower(implode('.', $names)) . '@test.lt');
$user->setRoles($type == 'user' ? ['ROLE_USER'] : ['ROLE_ADMIN']);
if ('unconfirmed' === $status) {
$user->setConfirmationToken(implode('-', array_map('strtolower', $names)) . '-token');
} else {
$encoder = $this->get('security.encoder_factory')->getEncoder($user);
$user->setPassword($encoder->encodePassword('S3cretpassword', $user->getSalt()));
}
$em->persist($user);
$em->flush();
return $user;
}
示例9: setFirstname
/**
* {@inheritDoc}
*/
public function setFirstname($firstname)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setFirstname', [$firstname]);
return parent::setFirstname($firstname);
}
示例10: thereIsUser
/**
* Create an user if he doesn't exists.
* @param $username
* @param $password
* @param null $role
* @param bool $create_entities
* @param string $enabled
* @param null $address
* @param array $groups
* @param bool $flush
* @return UserInterface
*/
public function thereIsUser($username, $password, $role = null, $create_entities = false, $enabled = 'yes', $address = null, $groups = array(), $flush = true)
{
$addressData = explode(',', $address);
$addressData = array_map('trim', $addressData);
if ($create_entities == true) {
$student_delegation = new StudentDelegation();
$student_delegation->setName($this->faker->word);
$student_delegation->setCity($this->faker->word);
$student_delegation->setProvince($this->faker->word);
$student_delegation->setPostcode($this->faker->boolean());
$student_delegation->setAddress($this->faker->word);
$student_delegation->setSlug($this->faker->word);
$college = new College();
$college->addStudentsDelegation($student_delegation);
$college->setName($this->faker->word);
$college->setCity($this->faker->word);
$college->setProvince($this->faker->word);
$college->setPostcode($this->faker->boolean());
$college->setAddress($this->faker->word);
$college->setSlug($this->faker->word);
$this->getEntityManager()->persist($college);
$university = new University();
$university->addCollege($college);
$university->setName($this->faker->word);
$university->setCity($this->faker->word);
$university->setProvince($this->faker->word);
$university->setCif($this->faker->word);
$university->setPostcode($this->faker->boolean());
$university->setAddress($this->faker->word);
$university->setType($this->faker->word);
$university->setSlug($this->faker->word);
$student_delegation->setCollege($college);
$college->setUniversity($university);
$this->getEntityManager()->persist($student_delegation);
$this->getEntityManager()->persist($university);
$this->getEntityManager()->flush();
}
/** @var User $user */
$user = new User();
$user->setUsername($username);
$user->setFirstname($this->faker->firstName);
$user->setLastname($this->faker->lastName);
$user->setFirstname(null === $address ? $this->faker->firstName : $addressData[0]);
$user->setLastname(null === $address ? $this->faker->lastName : $addressData[1]);
$user->setEmail($username . '@ritsiGA.com');
$user->setEnabled('yes' === $enabled);
$user->setPlainPassword($password);
if ($create_entities == true) {
$user->setStudentDelegation($student_delegation);
}
if (null !== $role) {
$user->addRole($role);
}
$this->getEntityManager()->persist($user);
foreach ($groups as $groupName) {
if ($group = $this->findOneByName('group', $groupName)) {
$user->addGroup($group);
}
}
if ($flush) {
$this->getEntityManager()->flush();
}
return $user;
}
示例11: getTop
public function getTop()
{
/**
* @TODO: FIX IT
* I don't know WHY but I couldn't add the upvoteTotal in the UserEntity...
* THUS, I have done a workaround thought out RAW SQL
*/
$result = $this->repository->getTop();
$data = array();
foreach ($result as $row) {
$user = new User();
$user->setId($row['id']);
$user->setFirstname($row['firstname']);
$user->setLastname($row['lastname']);
$user->setUsername($row['username']);
$user->setPicturePath($row['picture_path']);
$user->setUpvoteTotal($row['upvote_total']);
$data[] = $user;
}
return $data;
}