• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load

 public function load(ObjectManager $manager)
 {
     $encoder = $this->container->get('security.password_encoder');
     $userAdmin = new User();
     $userAdmin->setEmail('[email protected]');
     $userAdmin->setEnabled(1);
     $userAdmin->setUsername('Paul Mesnilgrente');
     $password = $encoder->encodePassword($userAdmin, 'lB7Xq9WdOxCz7Xzod1FH');
     $userAdmin->setPassword($password);
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $manager->persist($userAdmin);
     $manager->flush();
     $user1 = new User();
     $user1->setEmail('[email protected]');
     $user1->setEnabled(1);
     $user1->setUsername('Karol-anne Pelosato');
     $password = $encoder->encodePassword($user1, '2pMJVtuDtwkctwtf3fLQ');
     $user1->setPassword($password);
     $user1->setRoles(array('ROLE_USER'));
     $manager->persist($user1);
     $manager->flush();
     $user2 = new User();
     $user2->setEmail('[email protected]');
     $user2->setEnabled(1);
     $user2->setUsername('Fabien Mesnilgrente');
     $password = $encoder->encodePassword($user2, 'lv4Uem4OtFmfSYYDGX');
     $user2->setPassword($password);
     $user2->setRoles(array('ROLE_USER'));
     $manager->persist($user2);
     $manager->flush();
     $this->addReference('user-admin', $userAdmin);
     $this->addReference('user-karo', $user1);
     $this->addReference('user-fabien', $user2);
 }
开发者ID:paul-mesnilgrente,项目名称:paul-mesnilgrente,代码行数:34,代码来源:LoadUserData.php


示例2: load

 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername(self::TEST_USER_USERNAME)->setPlainPassword(self::TEST_USER_PASSWORD)->setRoles(['ROLE_ADMIN']);
     $manager->persist($user);
     $manager->flush();
 }
开发者ID:mkhrystunov,项目名称:guest_book,代码行数:10,代码来源:LoadUser.php


示例3: createToken

 /**
  * @param User $user
  * @return Token
  */
 public function createToken(User $user) : Token
 {
     $issued = Carbon::now();
     $expire = Carbon::now()->addSeconds((int) $this->config['expire']);
     $notBefore = Carbon::now()->addSeconds((int) $this->config['notbefore']);
     return $this->tokenBuilder->setIssuer($this->config['issuer'])->setAudience($this->config['audience'])->setId($this->config['appid'], true)->setIssuedAt($issued->getTimestamp())->setNotBefore($notBefore->getTimestamp())->setExpiration($expire->getTimestamp())->set('data', ["uid" => $user->getId(), "uidentifier" => $user->getUsername()])->sign($this->signer, $this->secret)->getToken();
 }
开发者ID:Algatux,项目名称:symfony3.0,代码行数:11,代码来源:TokenGenerator.php


示例4: createAnonymouslyAction

 /**
  * @Route("/record/anonymous", name="createRecordAnonymously")
  * @Method("POST")
  */
 public function createAnonymouslyAction(Request $request)
 {
     // user anonymous
     $repository = $this->getDoctrine()->getRepository('AppBundle:User');
     $count = $repository->count();
     $username = 'Player' . dechex($count);
     $password = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90));
     $user = new User();
     $user->setUsername($username);
     $user->setPassword(md5($password));
     $em = $this->getDoctrine()->getManager();
     $em->persist($user);
     $em->flush();
     // record
     $content = $request->getContent();
     $response = json_decode($content, true);
     if ($user != null) {
         $record = new Record();
         $record->setScore($response['score']);
         $record->setUserId($user->getId());
         $em = $this->getDoctrine()->getManager();
         $em->persist($record);
         $em->flush();
         return new JsonResponse(['code' => 1, 'record' => ['id' => $record->getId(), 'score' => $record->getScore(), 'userId' => $record->getUserId()], 'user' => ['username' => $user->getUsername(), 'password' => $password]]);
     } else {
         return new JsonResponse(['code' => 0, 'message' => 'record not save']);
     }
 }
开发者ID:8785496,项目名称:record,代码行数:32,代码来源:RecordController.php


示例5: startTestAction

 /**
  * @Route("/startTest", name="start_test")
  */
 public function startTestAction(Request $request)
 {
     $response = new Response();
     $response->headers->set('Content-Type', 'application/json');
     $data = json_decode($request->getContent(), true);
     $request->request->replace($data);
     //fetching user name
     if (!($userName = $request->request->get('user_name'))) {
         $response->setContent(json_encode(array('error' => 'Invalid name')));
         return $response;
     }
     //saving user
     $user = new User();
     $user->setName($userName);
     $user->setScore(0);
     $em = $this->getDoctrine()->getManager();
     $em->persist($user);
     $em->flush();
     //start sesssion
     $session = $request->getSession();
     $session->start();
     $session->set('user_id', $user->getId());
     $session->set('name', $user->getName());
     $session->set('score', $user->getScore());
     $session->set('errors_count', 0);
     $response->setContent(json_encode(array('success' => true)));
     return $response;
 }
开发者ID:virtyos,项目名称:dictionary,代码行数:31,代码来源:DefaultController.php


示例6: getRecentFrequent

 protected function getRecentFrequent(User $user, array $criteria = null, $limit = 10)
 {
     $sql = '
         SELECT text, MAX(createdAt) AS recency, COUNT(*) AS frequency
         FROM stress_log_factors
         JOIN stress_logs ON stress_log_id = stress_logs.id
         WHERE user_id = ?
     ';
     $params = array($user->getId());
     if (is_array($criteria)) {
         foreach ($criteria as $key => $val) {
             $op = '=';
             if (is_array($val)) {
                 reset($val);
                 $op = key($val);
                 $val = current($val);
             }
             $sql .= 'AND `' . $key . '` ' . $op . ' ? ';
             $params[] = $val;
         }
     }
     $sql .= 'GROUP BY text ';
     $sql .= 'ORDER BY recency DESC, frequency DESC ';
     $sql .= 'LIMIT ' . (int) $limit;
     $result = $this->conn->fetchAll($sql, $params);
     return array_column($result, 'text');
 }
开发者ID:jasongrimes,项目名称:stressmonkey,代码行数:27,代码来源:TagManager.php


示例7: geolocAction

 /**
  * @Route("/geoloc/{id}", requirements={"id" = "\d+"})
  * @Method("POST")
  */
 public function geolocAction($id)
 {
     $request = $this->getRequest();
     if ($request->isXmlHttpRequest()) {
         $em = $this->getDoctrine()->getManager();
         $wine = $em->getRepository('AppBundle:Wine')->find($id);
         if (null !== $wine) {
             $lat = $request->request->get('lat');
             $lng = $request->request->get('lng');
             if (null !== $lat && null !== $lng) {
                 $date = new \DateTime();
                 $user = new User();
                 $user->setLat($lat);
                 $user->setLng($lng);
                 $user->setDate($date);
                 $wine->addUser($user);
                 $em->persist($user);
                 $em->flush();
                 return new JsonResponse($this->normalizeJson($user), 200);
             }
         }
     } else {
         throw $this->createNotFoundException();
     }
     return new Response('', 200);
 }
开发者ID:potogan,项目名称:mobile-wine,代码行数:30,代码来源:DefaultController.php


示例8: loadUsers

 private function loadUsers(ObjectManager $manager)
 {
     $passwordEncoder = $this->container->get('security.password_encoder');
     $johnUser = new User();
     $johnUser->setUsername('john_user');
     $johnUser->setEmail('[email protected]');
     $encodedPassword = $passwordEncoder->encodePassword($johnUser, 'kitten');
     $johnUser->setPassword($encodedPassword);
     $manager->persist($johnUser);
     $annaAdmin = new User();
     $annaAdmin->setUsername('anna_admin');
     $annaAdmin->setEmail('[email protected]');
     $annaAdmin->setRoles(array('ROLE_ADMIN'));
     $encodedPassword = $passwordEncoder->encodePassword($annaAdmin, 'kitten');
     $annaAdmin->setPassword($encodedPassword);
     $manager->persist($annaAdmin);
     $avantripAdmin = new User();
     $avantripAdmin->setUsername('admin');
     $avantripAdmin->setEmail('[email protected]');
     $avantripAdmin->setRoles(array('ROLE_ADMIN'));
     $encodedPassword = $passwordEncoder->encodePassword($avantripAdmin, 'adminavantrip');
     $avantripAdmin->setPassword($encodedPassword);
     $manager->persist($avantripAdmin);
     $manager->flush();
 }
开发者ID:jbarad,项目名称:symfony_demo,代码行数:25,代码来源:LoadFixtures.php


示例9: registrationAction

 /**
  * @Route("/registration/new", name="registrationNew")
  */
 public function registrationAction(Request $request)
 {
     $user = new User();
     $user->setUsername(mb_strtolower($request->get('_username')));
     if ($request->get('_password') != $request->get('_password-2')) {
         $error = 'Пароли не совпадают';
         return $this->render(':user:registration.html.twig', array('error' => $error));
     }
     $plainPassword = $request->get('_password');
     $encoder = $this->container->get('security.password_encoder');
     $encoded = $encoder->encodePassword($user, $plainPassword);
     $user->setPassword($encoded);
     $user->setFirstName($request->get('_firstName'));
     $user->setSecondName($request->get('_secondName'));
     $user->setEmail($request->get('_email'));
     $user->setPost($request->get('_select'));
     //        $user->setRoles('ROLE_USER');
     $em = $this->getDoctrine()->getManager();
     try {
         $em->persist($user);
         $em->flush();
     } catch (\Exception $e) {
         $error = 'Логин уже занят';
         return $this->render(':user:registration.html.twig', array('error' => $error));
     }
     //        if ($this->isGranted('ROLE_ADMIN')) {
     //            return $this->showUserAction($user->getId());
     //        }
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'database_users', $user->getRoles());
     $this->get('security.token_storage')->setToken($token);
     return $this->redirectToRoute('userPage', array('id' => $user->getId()));
 }
开发者ID:AnastasiyaDev,项目名称:VisualizationModule,代码行数:35,代码来源:UserController.php


示例10: canSelfEdit

 /**
  * @param User $user
  * @return bool
  */
 private function canSelfEdit(User $user)
 {
     if ($user->getFacebookId() === null && $user->getGoogleId() === null && $user->getVkontakteId() === null) {
         return true;
     }
     return false;
 }
开发者ID:vsmihaylovsky,项目名称:GeekHubSymfonyShop,代码行数:11,代码来源:UserVoter.php


示例11: updatePassword

 private function updatePassword(User $entity)
 {
     if ($entity->getPlainPassword()) {
         $password = $this->encoder->encodePassword($entity, $entity->getPlainPassword());
         $entity->setPassword($password);
     }
 }
开发者ID:drymek,项目名称:fcs-backend,代码行数:7,代码来源:PasswordListener.php


示例12: authenticateUser

 private function authenticateUser(User $user)
 {
     $providerKey = 'frontend_area';
     // Firewall name
     $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
     $this->container->get('security.token_storage')->setToken($token);
 }
开发者ID:Wolframcheg,项目名称:symfonyblog,代码行数:7,代码来源:AuthController.php


示例13: getNotifications

 /**
  * @param User $user
  * @return array
  */
 public function getNotifications(User $user)
 {
     $qb = $this->createQueryBuilder('n');
     $qb->select('n.id, a.articleId, a.heading as article_heading, a.createdAt, u.username, img.path, v.heading as video_heading, v.videoId, l.linkId, l.heading as link_heading');
     $qb->leftJoin('n.article', 'a')->leftJoin('n.user', 'u')->leftJoin('u.profileImg', 'img')->leftJoin('n.video', 'v')->leftJoin('n.link', 'l')->where('a.userId = ' . $user->getId())->orWhere('v.userId = ' . $user->getId())->orWhere('l.userId = ' . $user->getId())->andWhere('n.seen = 0');
     return $qb->getQuery()->getResult();
 }
开发者ID:ugra92,项目名称:knowledgems,代码行数:11,代码来源:NotificationRepository.php


示例14: userNoModeratorAction

 /**
  * @Route("/user_no_moderator/{id}", name="admin_user_no_moderator")
  * @ParamConverter("user", options={"mapping": {"id": "id"}})
  */
 public function userNoModeratorAction(Request $request, User $user)
 {
     $user->removeRole('ROLE_MODERATOR');
     $em = $this->getDoctrine()->getEntityManager();
     $em->flush();
     return $this->redirectToRoute('admin_users_show');
 }
开发者ID:KateSyrotchuk,项目名称:blog,代码行数:11,代码来源:UserController.php


示例15: commit

 /**
  * @param User $user
  * @param PageAnimal $pageAnimal
  * @throws HistoryException
  * @throws ValidationException
  */
 public function commit(User $user, PageAnimal $pageAnimal)
 {
     /** @var PageAnimalBranch $pageAnimalBranch */
     $pageAnimalBranch = $this->pageAnimalBranchRepository->find($pageAnimal->getId());
     if ($pageAnimalBranch == null) {
         throw new HistoryException(HistoryException::BRANCHE_INCONNUE);
     }
     if ($user->getId() !== $pageAnimalBranch->getOwner()->getId()) {
         throw new HistoryException(HistoryException::DROIT_REFUSE);
     }
     /** @var PageAnimalCommit $clientHead */
     $clientHead = $this->pageAnimalCommitRepository->find($pageAnimal->getHead());
     if ($clientHead->getId() !== $pageAnimalBranch->getCommit()->getId()) {
         throw new HistoryException(HistoryException::NON_FAST_FORWARD);
     }
     if (empty($pageAnimal->getNom())) {
         throw new ValidationException(ValidationException::EMPTY_NOM);
     }
     if (empty($pageAnimal->getDateNaissance())) {
         throw new ValidationException(ValidationException::EMPTY_DATE_NAISSANCE);
     }
     $commit = new PageAnimalCommit($clientHead, $pageAnimal->getNom(), $pageAnimal->getDateNaissance(), $pageAnimal->getDescription(), $pageAnimal->getStatut(), $pageAnimal->getSexe(), $pageAnimal->getPhotos());
     $this->doctrine->persist($commit);
     $pageAnimalBranch->setCommit($commit);
     $this->doctrine->flush([$commit, $pageAnimalBranch]);
     $pageAnimal->setHead($commit->getId());
 }
开发者ID:apflieger,项目名称:zigotoo,代码行数:33,代码来源:PageAnimalService.php


示例16: 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()));
 }
开发者ID:gikusan,项目名称:ProyectoSymfony,代码行数:28,代码来源:RegistrationController.php


示例17: authenticate

 /**
  * 认证用户
  */
 public function authenticate(User $user, $providerKey)
 {
     $authenticationToken = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
     $authenticationEvent = new InteractiveLoginEvent($this->request, $authenticationToken);
     $this->tokenStorage->setToken($authenticationToken);
     $this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $authenticationEvent);
 }
开发者ID:timy-life,项目名称:segments,代码行数:10,代码来源:SymfonyAuthenticationService.php


示例18: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $passwordEncoder = $this->container->get('security.password_encoder');
     $joeUser = new User();
     $joeUser->setUsername('joe_user');
     $joeUser->setEmail('[email protected]');
     $encodedPassword = $passwordEncoder->encodePassword($joeUser, 'pa$$word');
     $joeUser->setPassword($encodedPassword);
     $joeUser->setEnabled(true);
     $manager->persist($joeUser);
     $this->setReference('user-joe_user', $joeUser);
     $johnAdmin = new User();
     $johnAdmin->setUsername('john_admin');
     $johnAdmin->setEmail('[email protected]');
     $johnAdmin->setRoles(array('ROLE_ADMIN'));
     $encodedPassword = $passwordEncoder->encodePassword($johnAdmin, 'pa$$word');
     $johnAdmin->setPassword($encodedPassword);
     $johnAdmin->setEnabled(true);
     $manager->persist($johnAdmin);
     $this->setReference('user-john_admin', $johnAdmin);
     $jackSuper = new User();
     $jackSuper->setUsername('jack_super');
     $jackSuper->setEmail('[email protected]');
     $jackSuper->setRoles(array('ROLE_SUPER_ADMIN'));
     $encodedPassword = $passwordEncoder->encodePassword($jackSuper, 'pa$$word');
     $jackSuper->setPassword($encodedPassword);
     $jackSuper->setEnabled(true);
     $manager->persist($jackSuper);
     $this->setReference('user-jack_super', $jackSuper);
     $manager->flush();
 }
开发者ID:sandraf,项目名称:symfony2-project,代码行数:34,代码来源:LoadUserData.php


示例19: disableUserAction

 /**
  * @Route("/admin/{user}/desable", name="enable_user")
  */
 public function disableUserAction(User $user)
 {
     $user->disable();
     $this->getDoctrine()->getManager()->flush();
     $this->addFlash('success', sprintf('"%s" has been disabled.'));
     return $this->redirectToRoute('list_users');
 }
开发者ID:saro0h,项目名称:sitandgo,代码行数:10,代码来源:UserController.php


示例20: checkUserLabeli

 public function checkUserLabeli(User $user)
 {
     $userNom = strtolower($user->getNom());
     $userPrenom = strtolower($user->getPrenom());
     $userMail = strtolower($user->getEmail());
     $labelis = $this->em->getRepository('AppBundle:Labeli')->findAll();
     foreach ($labelis as $labeli) {
         $labeliNom = strtolower($labeli->getNom());
         $labeliPrenom = strtolower($labeli->getPrenom());
         $labeliMail = strtolower($labeli->getMail());
         if ($userNom == $labeliNom && $userPrenom == $labeliPrenom || $userPrenom == $labeliNom && $userNom == $labeliPrenom || $userMail == $labeliMail) {
             if ($labeli->getHonored() == 1) {
                 $subject = 'Confirmation Invités d\'Honneur LGC';
                 $template = '::email/honored.html.twig';
             } else {
                 $subject = 'Confirmation participant Label[i]';
                 $template = '::email/labeli.html.twig';
             }
             $user->setPayed(1);
             $this->em->flush();
             $mailUser = $user->getEmail();
             $message = \Swift_Message::newInstance()->setSubject($subject)->setFrom('[email protected]')->setTo($userMail)->setBody($this->container->get('templating')->render($template), 'text/html');
             $this->container->get('mailer')->send($message);
             $user->setMailPayed(1);
             $this->em->persist($user);
             $this->em->flush();
         }
     }
 }
开发者ID:NanaRT,项目名称:labelilan,代码行数:29,代码来源:ApplicationListener.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP utils\Ibos类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\Post类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap