本文整理汇总了PHP中AppBundle\Entity\User::setIsActive方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setIsActive方法的具体用法?PHP User::setIsActive怎么用?PHP User::setIsActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setIsActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadUserByOAuthUserResponse
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
try {
$resourceOwnerName = $response->getResourceOwner()->getName();
if (!isset($this->properties[$resourceOwnerName])) {
throw new \RuntimeException(sprintf("No property defined for entity for resource owner '%s'.", $resourceOwnerName));
}
$username = $response->getUsername();
if (null === ($user = $this->repository->findOneBy(array($this->properties[$resourceOwnerName] => $username)))) {
throw new UsernameNotFoundException(sprintf("User '%s' not found.", $username));
}
return $user;
} catch (UsernameNotFoundException $e) {
$rawResponse = $response->getResponse();
$user = new User($rawResponse['screen_name']);
$user->setTwitterId($rawResponse['id']);
$user->setUsername($rawResponse['screen_name']);
$user->setTodaySinceId('');
$user->setIsActive(true);
$user->setCreateAt(new \DateTime());
$user->setUpdateAt(new \DateTime());
$this->em->persist($user);
$this->em->flush();
return $user;
}
}
示例2: 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;
}
示例3: registerAction
/**
* @Route("/register", name="registration")
*/
public function registerAction(Request $request)
{
// 1) build the form
$user = new User();
$user->setIsActive(false);
$user->setIsAdmin(false);
$form = $this->createForm(new UserType(), $user);
// 2) handle the submit (will only happen on POST)
$form->handleRequest($request);
if (!$form->isValid()) {
echo $form->getErrorsAsString();
}
if ($form->isValid() && $form->isSubmitted()) {
$user->setPassword($user->getPlainPassword());
$user->setIsActive(false);
// 4) save the User!
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
// ... do any other work - like send them an email, etc
// maybe set a "flash" success message for the user
return new Response("<html>USUARIO REGISTRADO CORRECTAMENTE</html>");
}
return $this->render('registration/register.html.twig', array('form' => $form->createView()));
}
示例4: userUnlockedAction
/**
* @Route("/user_unlocked/{id}", name="admin_user_unlocked")
* @ParamConverter("user", options={"mapping": {"id": "id"}})
*/
public function userUnlockedAction(Request $request, User $user)
{
$user->setIsActive(true);
$em = $this->getDoctrine()->getEntityManager();
$em->flush();
return $this->redirectToRoute('admin_users_show');
}
示例5: testSetIsActive
public function testSetIsActive()
{
// new entity
$user = new User();
// Use the setIsActive method
$user->setIsActive(1);
// Assert the result
$this->assertEquals(1, $user->getIsActive());
}
示例6: load
/**
* Load data fixtures with the passed EntityManager
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$passwordEncoder = $this->container->get('security.password_encoder');
$user = new User();
$user->setEmail('fix@fix.com');
$user->setIsActive(true);
$user->setPassword($passwordEncoder->encodePassword($user, '12345'));
$user->setUsername('fix');
$manager->persist($user);
$manager->flush();
}
示例7: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$user = new User();
$user->setUsername('admin');
$user->setEmail('kamalsolimen@gmail.com');
$user->setIsActive(1);
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
$user->setPassword($encoder->encodePassword('test', null));
$manager->persist($user);
$manager->flush();
}
示例8: testBasicGettersSetters
public function testBasicGettersSetters()
{
$user = new User();
$user->setUsername('Toto');
$user->setEmail('toto@tata.com');
$user->setIsActive(false);
$user->setPassword('1234');
$this->assertEquals('Toto', $user->getUsername());
$this->assertEquals('toto@tata.com', $user->getEmail());
$this->assertEquals(false, $user->isActive());
$this->assertEquals('1234', $user->getPassword());
}
示例9: createEntity
private function createEntity($username, $password, $email)
{
$securityEncodeFactory = $this->getContainer()->get('security.encoder_factory');
$em = $this->getContainer()->get('doctrine')->getEntityManager();
$groupRepo = $em->getRepository('AppBundle\\Entity\\Group');
$roleAdminGroup = $groupRepo->findOneByRole('ROLE_ADMIN');
$user = new User();
$user->setUsername($username);
$user->setPassword($password);
$user->setEmail($email);
$user->addGroup($roleAdminGroup);
$user->setIsActive(true);
$encoder = $securityEncodeFactory->getEncoder($user);
$password = $encoder->encodePassword($user->getPassword(), $user->getSalt());
$user->setPassword($password);
return $user;
}
示例10: registerAction
/**
* @Route("/register", name="user_registration")
*/
public function registerAction(Request $request)
{
// 1) build the form
$user = new User();
$user->setIsActive(true);
$user->setIsAdmin(false);
$form = $this->createForm(UserType::class, $user);
// 2) handle the submit (will only happen on POST)
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// 3) Encode the password (you could also do this via Doctrine listener)
$password = $this->get('security.password_encoder')->encodePassword($user, $user->getPlainPassword());
$user->setPassword($password);
// 4) save the User!
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
// ... do any other work - like send them an email, etc
// maybe set a "flash" success message for the user
return $this->redirectToRoute('homepage');
}
return $this->render('security/register.html.twig', array('form' => $form->createView()));
}
示例11: 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');
//.........这里部分代码省略.........
示例12: registerPostAction
public function registerPostAction(Request $request)
{
$response = new Response();
$data = json_decode($request->getContent(), true);
if ($data['username'] === null || $data['password'] === null) {
return $response->setContent(json_encode(['errorMessage' => 'You must pass username and password']));
} else {
/** @var EncoderFactory $factory */
$factory = $this->get('security.encoder_factory');
$em = $this->getDoctrine()->getManager();
$user = new User();
$user->setRole(new Role());
$user->setIsActive(false);
$user->setUsername($data['username']);
$user->setPassword($data['password']);
/** @var Validator $validator */
$validator = $this->get('validator');
/** @var ConstraintViolationList $errors */
$errors = $validator->validate($user);
if (count($errors) > 0) {
$errorMessage = '';
foreach ($errors as $error) {
$errorMessage .= $error->getMessage();
}
return $response->setContent(json_encode(['errorMessage' => $errorMessage]));
} else {
/** @var PasswordEncoderInterface $encoder */
$encoder = $factory->getEncoder($user);
$password = $encoder->encodePassword($data['password'], $user->getSalt());
$user->setPassword($password);
$em->persist($user);
$em->flush();
return $response->setContent(json_encode(['message' => 'User successfully has registered.']));
}
}
}
示例13: 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]);
}
}
示例14: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$belacUser = new User();
$belacUser->setUsername('belac');
$belacUser->setEmail('belackriv@gmail.com');
$belacUser->setFirstName('Belac');
$belacUser->setLastName('Kriv');
$belacUser->setIsActive(true);
$belacUser->setDefaultDepartment($this->getReference('stepDept'));
$belacUser->setOrganization($this->getReference('stepOrg'));
$belacUserRole = new UserRole();
$belacUserRole->setUser($belacUser);
$belacUserRole->setRole($this->getReference('ROLE_DEV'));
$belacUser->addUserRole($belacUserRole);
$belacPassword = 'password';
$encoder = $this->container->get('security.password_encoder');
$encoded = $encoder->encodePassword($belacUser, $belacPassword);
$belacUser->setPassword($encoded);
$manager->persist($belacUser);
$plainUser = new User();
$plainUser->setUsername('usertest');
$plainUser->setEmail('user@none');
$plainUser->setFirstName('User');
$plainUser->setLastName('Test');
$plainUser->setIsActive(true);
$plainUser->setDefaultDepartment($this->getReference('oneOne'));
$plainUser->setOrganization($this->getReference('demoOrg'));
$plainUserRole = new UserRole();
$plainUserRole->setUser($plainUser);
$plainUserRole->setRole($this->getReference('ROLE_USER'));
$plainUser->addUserRole($plainUserRole);
$plainPassword = 'password';
$encoder = $this->container->get('security.password_encoder');
$encoded = $encoder->encodePassword($plainUser, $plainPassword);
$plainUser->setPassword($encoded);
$manager->persist($plainUser);
$leadUser = new User();
$leadUser->setUsername('leadtest');
$leadUser->setEmail('lead@none');
$leadUser->setFirstName('Lead');
$leadUser->setLastName('Test');
$leadUser->setIsActive(true);
$leadUser->setDefaultDepartment($this->getReference('oneOne'));
$leadUser->setOrganization($this->getReference('demoOrg'));
$leadUserRole = new UserRole();
$leadUserRole->setUser($leadUser);
$leadUserRole->setRole($this->getReference('ROLE_LEAD'));
$leadUser->addUserRole($leadUserRole);
$leadPassword = 'password';
$encoder = $this->container->get('security.password_encoder');
$encoded = $encoder->encodePassword($leadUser, $leadPassword);
$leadUser->setPassword($encoded);
$manager->persist($leadUser);
$adminUser = new User();
$adminUser->setUsername('admintest');
$adminUser->setEmail('admin@none');
$adminUser->setFirstName('Admin');
$adminUser->setLastName('Test');
$adminUser->setIsActive(true);
$adminUser->setDefaultDepartment($this->getReference('oneOne'));
$adminUser->setOrganization($this->getReference('demoOrg'));
$adminUserRole = new UserRole();
$adminUserRole->setUser($adminUser);
$adminUserRole->setRole($this->getReference('ROLE_ADMIN'));
$adminUser->addUserRole($adminUserRole);
$adminPassword = 'password';
$encoder = $this->container->get('security.password_encoder');
$encoded = $encoder->encodePassword($adminUser, $adminPassword);
$adminUser->setPassword($encoded);
$manager->persist($adminUser);
$manager->flush();
$aclProvider = $this->container->get('security.acl.provider');
$devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
$adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
$leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
$userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
$objectIdentity = ObjectIdentity::fromDomainObject($belacUser);
$acl = $aclProvider->createAcl($objectIdentity);
$acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
$acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
$aclProvider->updateAcl($acl);
$objectIdentity = ObjectIdentity::fromDomainObject($belacUserRole);
$acl = $aclProvider->createAcl($objectIdentity);
$acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
$acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
$aclProvider->updateAcl($acl);
$objectIdentity = ObjectIdentity::fromDomainObject($plainUser);
$acl = $aclProvider->createAcl($objectIdentity);
$acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
$acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
$aclProvider->updateAcl($acl);
$objectIdentity = ObjectIdentity::fromDomainObject($plainUserRole);
$acl = $aclProvider->createAcl($objectIdentity);
$acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
$acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
$aclProvider->updateAcl($acl);
$objectIdentity = ObjectIdentity::fromDomainObject($leadUser);
//.........这里部分代码省略.........
示例15: setIsActive
/**
* {@inheritDoc}
*/
public function setIsActive($isActive)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setIsActive', array($isActive));
return parent::setIsActive($isActive);
}