本文整理汇总了PHP中AppBundle\Entity\User::setActive方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setActive方法的具体用法?PHP User::setActive怎么用?PHP User::setActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setActive方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @Route("/admin/student/create")
*/
public function create(Request $request)
{
$user = new User();
$user->setActive(true);
$form = $this->createFormBuilder($user)->add('lastName', 'text', array('label' => 'Last Name:'))->add('firstName', 'text', array('label' => 'First Name:'))->add('englishName', 'text', array('label' => 'English Name:'))->add('username', 'text', array('label' => 'Username', 'empty_data' => md5(time()), 'data' => md5(time())))->add('password', 'text', array('label' => 'Password', 'empty_data' => md5(time()), 'data' => md5(time())))->add('email', 'text', array('label' => 'Email', 'empty_data' => md5(md5(time())) . "@stsergiuslc.com", 'data' => md5(md5(time())) . "@stsergiuslc.com"))->add('classes', 'entity', array('multiple' => true, 'expanded' => true, 'class' => 'AppBundle:ClassOfStudents', 'choice_label' => 'name', 'label' => 'Class: ', 'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('p')->leftJoin('p.year', 'y')->where('y.active=:active')->orderBy('p.ordinal', 'ASC')->setParameter('active', true);
}))->add('save', 'submit', array('label' => 'Create student'))->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$user = $form->getData();
$em = $this->getDoctrine()->getManager();
$roles = $this->getDoctrine()->getRepository('AppBundle:Role')->findOneById(3);
$user->addRole($roles);
$em->persist($user);
$em->flush();
return $this->redirectToRoute($this->studentAdminRoute);
}
return $this->render('forms/student.html.twig', array('form' => $form->createView()));
}
示例2: create
/**
* @Route("/admin/teacher/create")
*/
public function create(Request $request)
{
$user = new User();
$user->setActive(true);
$roles = $this->getDoctrine()->getRepository('AppBundle:Role')->findOneById(2);
$user->addRole($roles);
$form = $this->createFormBuilder($user)->add('lastName', 'text', array('label' => 'Last Name:'))->add('firstName', 'text', array('label' => 'First Name:'))->add('englishName', 'text', array('label' => 'English Name:'))->add('username', 'text', array('label' => 'Login:'))->add('password', 'repeated', array('type' => 'password', 'invalid_message' => 'Password fields do not match', 'first_options' => array('label' => 'Password', 'required' => false), 'second_options' => array('label' => 'Repeat Password', 'required' => false)))->add('email', 'text', array('label' => 'Email:', 'required' => false))->add('mobilePhone', 'text', array('label' => 'Mobile Phone:', 'required' => false))->add('homePhone', 'text', array('label' => 'Home Phone:', 'required' => false))->add('roles', 'entity', array('multiple' => true, 'expanded' => true, 'class' => 'AppBundle:Role', 'choice_label' => 'name', 'label' => 'Roles: '))->add('save', 'submit', array('label' => 'Create'))->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$user = $form->getData();
$em = $this->getDoctrine()->getManager();
if ($user->getPassword() != '') {
$user->setPassword(md5($user->getPassword()));
}
$em->persist($user);
$em->flush();
return $this->redirectToRoute($this->displayRoute);
}
return $this->render('forms/teacher.html.twig', array('form' => $form->createView()));
}
示例3: create
/**
* @Route("/admin/user/create")
*/
public function create(Request $request)
{
$user = new User();
$user->setActive(true);
$form = $this->createFormBuilder($user)->add('lastName', 'text', array('label' => 'Last Name:'))->add('firstName', 'text', array('label' => 'First Name:'))->add('englishName', 'text', array('label' => 'English Name:'))->add('username', 'text', array('label' => 'Login:'))->add('password', 'repeated', array('type' => 'password', 'invalid_message' => 'Password fields do not match', 'first_options' => array('label' => 'Password', 'always_empty' => false), 'second_options' => array('label' => 'Repeat Password', 'always_empty' => false)))->add('dob', 'date', array('label' => 'Date of birth:', 'years' => range(date('Y'), date('Y') - 100)))->add('email', 'text', array('label' => 'Email:', 'required' => false))->add('mobilePhone', 'text', array('label' => 'Mobile Phone:', 'required' => false))->add('homePhone', 'text', array('label' => 'Home Phone:', 'required' => false))->add('active', 'checkbox', array('label' => 'Active', 'required' => false))->add('roles', 'entity', array('multiple' => true, 'expanded' => true, 'class' => 'AppBundle:Role', 'choice_label' => 'name', 'label' => 'Roles: '))->add('save', 'submit', array('label' => 'Create user'))->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$user = $form->getData();
$em = $this->getDoctrine()->getManager();
if ($user->getPassword() != '') {
#$options = array('cost' => 11);
$user->setPassword(md5($user->getPassword()));
#$user->setPassword(password_hash($user->getPassword(), PASSWORD_SHA512, $options));
}
$em->persist($user);
$em->flush();
return $this->redirectToRoute($this->displayRoute);
}
return $this->render('forms/user.html.twig', array('form' => $form->createView()));
}
示例4: create
/**
* @Route("/admin/parent/create")
*/
public function create(Request $request)
{
$user = new User();
$user->setActive(true);
$form = $this->createFormBuilder($user)->add('lastName', 'text', array('label' => 'Last Name:'))->add('firstName', 'text', array('label' => 'First Name:'))->add('englishName', 'text', array('label' => 'English Name:'))->add('username', 'text', array('label' => 'Login:'))->add('password', 'repeated', array('type' => 'password', 'invalid_message' => 'Password fields do not match', 'first_options' => array('label' => 'Password', 'required' => false), 'second_options' => array('label' => 'Repeat Password', 'required' => false)))->add('email', 'text', array('label' => 'Email:', 'required' => false))->add('mobilePhone', 'text', array('label' => 'Phone:', 'required' => false))->add('students', 'entity', array('label' => 'Parent of students: ', 'multiple' => true, 'expanded' => true, 'class' => 'AppBundle:User', 'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')->join('u.roles', 'r')->where('r.role = :role')->andWhere('u.active = true')->orderBy('u.lastName')->setParameter('role', 'ROLE_STUDENT');
}))->add('save', 'submit', array('label' => 'Create'))->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$user = $form->getData();
$em = $this->getDoctrine()->getManager();
if ($user->getPassword() != '') {
$user->setPassword(md5($user->getPassword()));
}
$roles = $this->getDoctrine()->getRepository('AppBundle:Role')->findOneById(4);
$user->addRole($roles);
$em->persist($user);
$em->flush();
return $this->redirectToRoute($this->displayRoute);
}
return $this->render('forms/parent.html.twig', array('form' => $form->createView()));
}
示例5: createData
/**
* @Route("dane/dodaj")
*/
public function createData()
{
$mainCategory = new Category();
$mainCategory->setCategory(null);
$mainCategory->setActive(1);
$mainCategory->setName('Główne');
$em = $this->getDoctrine()->getManager();
$em->persist($mainCategory);
$em->flush();
$foodCategory = new Category();
$foodCategory->setCategory($mainCategory);
$foodCategory->setActive(1);
$foodCategory->setName('Żywność');
$em = $this->getDoctrine()->getManager();
$em->persist($foodCategory);
$em->flush();
$drugCategory = new Category();
$drugCategory->setCategory($mainCategory);
$drugCategory->setActive(1);
$drugCategory->setName('Używki');
$em = $this->getDoctrine()->getManager();
$em->persist($drugCategory);
$em->flush();
$serviceCategory = new Category();
$serviceCategory->setCategory($mainCategory);
$serviceCategory->setActive(1);
$serviceCategory->setName('Usługi');
$em = $this->getDoctrine()->getManager();
$em->persist($serviceCategory);
$em->flush();
$industryCategory = new Category();
$industryCategory->setCategory($mainCategory);
$industryCategory->setActive(1);
$industryCategory->setName('Przemysł');
$em = $this->getDoctrine()->getManager();
$em->persist($industryCategory);
$em->flush();
$scienceCategory = new Category();
$scienceCategory->setCategory($mainCategory);
$scienceCategory->setActive(1);
$scienceCategory->setName('Nauka, Edukacja');
$em = $this->getDoctrine()->getManager();
$em->persist($scienceCategory);
$em->flush();
$privateLessonCategory = new Category();
$privateLessonCategory->setCategory($scienceCategory);
$privateLessonCategory->setActive(1);
$privateLessonCategory->setName('Korepetycje');
$em = $this->getDoctrine()->getManager();
$em->persist($privateLessonCategory);
$em->flush();
$beforeSchoolCategory = new Category();
$beforeSchoolCategory->setCategory($scienceCategory);
$beforeSchoolCategory->setActive(1);
$beforeSchoolCategory->setName('Przedszkola');
$em = $this->getDoctrine()->getManager();
$em->persist($beforeSchoolCategory);
$em->flush();
$nurseryCategory = new Category();
$nurseryCategory->setCategory($scienceCategory);
$nurseryCategory->setActive(1);
$nurseryCategory->setName('Żłobki');
$em = $this->getDoctrine()->getManager();
$em->persist($nurseryCategory);
$em->flush();
$wholePolandProvince = new Province();
$wholePolandProvince->setActive(1);
$wholePolandProvince->setName('Cała Polska');
$em = $this->getDoctrine()->getManager();
$em->persist($wholePolandProvince);
$em->flush();
$mazowieckieProvince = new Province();
$mazowieckieProvince->setActive(1);
$mazowieckieProvince->setName('Mazowieckie');
$em = $this->getDoctrine()->getManager();
$em->persist($mazowieckieProvince);
$em->flush();
$dolnoslaskieProvince = new Province();
$dolnoslaskieProvince->setActive(1);
$dolnoslaskieProvince->setName('Dolnośląskie');
$em = $this->getDoctrine()->getManager();
$em->persist($dolnoslaskieProvince);
$em->flush();
$warminskoMazurskieProvince = new Province();
$warminskoMazurskieProvince->setActive(1);
$warminskoMazurskieProvince->setName('Warmińsko-Mazurskie');
$em = $this->getDoctrine()->getManager();
$em->persist($warminskoMazurskieProvince);
$em->flush();
$opolskieProvince = new Province();
$opolskieProvince->setActive(1);
$opolskieProvince->setName('Opolskie');
$em = $this->getDoctrine()->getManager();
$em->persist($opolskieProvince);
$em->flush();
$slaskieProvince = new Province();
$slaskieProvince->setActive(1);
//.........这里部分代码省略.........
示例6: 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()));
}