当前位置: 首页>>代码示例>>PHP>>正文


PHP Model\UserManagerInterface类代码示例

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


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

示例1: techRegister

 private function techRegister($form, $request, \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher, \FOS\UserBundle\Model\UserManagerInterface $userManager, $user)
 {
     $event = new FormEvent($form, $request);
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
     $userManager->updateUser($user);
     if (null === ($response = $event->getResponse())) {
         $url = $this->container->get('router')->generate('fos_user_registration_confirmed');
         $response = new RedirectResponse($url);
     }
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
     return $response;
 }
开发者ID:Nosolok,项目名称:UtopiaMud,代码行数:12,代码来源:RegistrationController.php

示例2: create

 /**
  * Creates a user and returns it.
  *
  * @param string $username
  * @param string $password
  * @param string $email
  * @param bool   $active
  * @param bool   $superadmin
  *
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $active, $superadmin)
 {
     $discriminator = $this->discriminator;
     switch ($this->type) {
         case 'staff':
             $class = 'Truckee\\MatchBundle\\Entity\\Staff';
             break;
         case 'admin':
             $class = 'Truckee\\MatchBundle\\Entity\\Admin';
             break;
         case 'volunteer':
             $class = 'Truckee\\MatchBundle\\Entity\\Volunteer';
             break;
         default:
             break;
     }
     $discriminator->setClass($class);
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setFirstname($this->firstname);
     $user->setLastname($this->lastname);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled((bool) $active);
     $this->userManager->updateUser($user, true);
     return $user;
 }
开发者ID:truckee,项目名称:match,代码行数:38,代码来源:UserManipulator.php

示例3: postBind

 public function postBind(DataEvent $event)
 {
     $user = $event->getForm()->getData();
     if ($user instanceof UserInterface) {
         $this->userManager->updateCanonicalFields($user);
     }
 }
开发者ID:helmer,项目名称:UserBundle,代码行数:7,代码来源:UpdateCanonicalFieldsListener.php

示例4: __invoke

 public function __invoke(Request $request)
 {
     if ($this->container->hasParameter('partkeepr.auth.allow_password_change') && $this->container->getParameter('partkeepr.auth.allow_password_change') === false) {
         throw new PasswordChangeNotAllowedException();
     }
     $user = $this->userService->getUser();
     if (!$request->request->has('oldpassword') && !$request->request->has('newpassword')) {
         throw new \Exception('old password and new password need to be specified');
     }
     $FOSUser = $this->userManager->findUserByUsername($user->getUsername());
     if ($FOSUser !== null) {
         $encoder = $this->encoderFactory->getEncoder($FOSUser);
         $encoded_pass = $encoder->encodePassword($request->request->get('oldpassword'), $FOSUser->getSalt());
         if ($FOSUser->getPassword() != $encoded_pass) {
             throw new OldPasswordWrongException();
         }
         $this->userManipulator->changePassword($user->getUsername(), $request->request->get('newpassword'));
     } else {
         if ($user->isLegacy()) {
             if ($user->getPassword() !== md5($request->request->get('oldpassword'))) {
                 throw new OldPasswordWrongException();
             }
             $user->setNewPassword($request->request->get('newpassword'));
             $this->userService->syncData($user);
         } else {
             throw new \Exception('Cannot change password for LDAP users');
         }
     }
     $user->setPassword('');
     $user->setNewPassword('');
     return $user;
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:32,代码来源:ChangePasswordAction.php

示例5: onSuccess

 /**
  * @param UserInterface $user
  */
 protected function onSuccess(UserInterface $user)
 {
     if ($this->getNewPassword() != "") {
         $user->setPlainPassword($this->getNewPassword());
     }
     $this->userManager->updateUser($user);
 }
开发者ID:Tagarela76,项目名称:table4you,代码行数:10,代码来源:ProfileFormHandler.php

示例6: updateUserFields

 /**
  * This must be called on prePersist and preUpdate if the event is about a
  * user.
  *
  * @param UserInterface $user
  */
 protected function updateUserFields(UserInterface $user)
 {
     if (null === $this->userManager) {
         $this->userManager = $this->container->get('fos_user.user_manager');
     }
     $this->userManager->updateCanonicalFields($user);
     $this->userManager->updatePassword($user);
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:14,代码来源:AbstractUserListener.php

示例7: findUserByUsernameOrThrowException

 /**
  * Finds a user by his username and throws an exception if we can't find it.
  *
  * @param string $username
  *
  * @throws \InvalidArgumentException When user does not exist
  *
  * @return UserInterface
  */
 private function findUserByUsernameOrThrowException($username)
 {
     $user = $this->userManager->findUserByUsername($username);
     if (!$user) {
         throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username));
     }
     return $user;
 }
开发者ID:Jheengut,项目名称:linuxcounter.new,代码行数:17,代码来源:UserManipulator.php

示例8: deleteObject

 /**
  * Removes the given user object.
  *
  * @param DataEvent $event
  */
 public function deleteObject(DataEvent $event)
 {
     $object = $event->getData();
     if ($object instanceof UserInterface) {
         $this->userManager->deleteUser($object);
         $this->eventDispatcher->dispatch(Events::POST_DELETE, $event);
         $event->stopPropagation();
     }
 }
开发者ID:reminec,项目名称:DunglasApiBundle,代码行数:14,代码来源:EventSubscriber.php

示例9: createUserFromResponse

 /**
  * Create user from response
  *
  * @param UserResponseInterface $response
  *
  * @return User
  */
 private function createUserFromResponse(UserResponseInterface $response)
 {
     /** @var User $user User */
     $user = $this->userManager->createUser();
     $user->setUsername($response->getUsername())->setFullName($response->getRealName())->setEmail($response->getEmail())->setEnabled(true)->setPlainPassword(uniqid())->setFacebookId($response->getUsername())->setFacebookAccessToken($response->getAccessToken());
     $this->eventDispatcher->dispatch(AppEvents::FACEBOOK_USER_CONNECTED, new FacebookUserConnectedEvent($user));
     $this->userManager->updateUser($user);
     return $user;
 }
开发者ID:stfalcon-studio,项目名称:lost-and-found,代码行数:16,代码来源:AuthProvider.php

示例10: getNbUnreadByUsername

 public function getNbUnreadByUsername($username)
 {
     $nb = apc_fetch('nbm.' . $username);
     if (false === $nb) {
         $user = $this->userManager->findUserByUsername($username);
         $nb = $this->updateNbUnread($participant);
     }
     return $nb;
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:9,代码来源:Cache.php

示例11: onSecurityInteractiveLogin

 /**
  * handle user Ip log to users table, after login, with security.interactive_login kernel event.
  *
  * @param InteractiveLoginEvent $event
  */
 public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
 {
     $user = $event->getAuthenticationToken()->getUser();
     if ($user instanceof UserInterface) {
         $ipAddress = $this->requestStack->getCurrentRequest()->server->get('REMOTE_ADDR');
         $user->setLastloginClientIp($ipAddress);
         $this->userManager->updateUser($user);
     }
 }
开发者ID:extdevelopment,项目名称:login-task,代码行数:14,代码来源:InteractiveLoginListener.php

示例12: createModelInstance

 protected function createModelInstance()
 {
     $message = parent::createModelInstance();
     if ($to = $this->request->query->get('to')) {
         if ($recipient = $this->userManager->findUserByUsername($to)) {
             $message->setRecipient($recipient);
         }
     }
     return $message;
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:10,代码来源:NewThreadMessageFormFactory.php

示例13: reverseTransform

 /**
  * Transforms a username string into a UserInterface instance.
  *
  * @param string $value Username
  *
  * @return UserInterface the corresponding UserInterface instance
  *
  * @throws UnexpectedTypeException if the given value is not a string
  */
 public function reverseTransform($value)
 {
     if (null === $value || '' === $value) {
         return null;
     }
     if (!is_string($value)) {
         throw new UnexpectedTypeException($value, 'string');
     }
     return $this->userManager->findUserByUsername($value);
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:19,代码来源:UserToUsernameTransformer.php

示例14: getUserByEmailPw

 /**
  * @param string $email
  * @param string $pw
  * @return \FOS\UserBundle\Model\UserInterface|null
  */
 function getUserByEmailPw($email, $pw)
 {
     $result = null;
     if ($email && $pw) {
         $user = $this->_fosUserManager->findUserByEmail($email);
         if ($user && $this->isPasswordValid($user, $pw)) {
             $result = $user;
         }
     }
     return $result;
 }
开发者ID:appsco,项目名称:component-share,代码行数:16,代码来源:FosUserProvider.php

示例15: isValid

 /**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constrain for the validation
  *
  * @return Boolean Whether or not the value is valid
  *
  * @throws UnexpectedTypeException if $value is not instance of \FOS\UserBundle\Model\UserInterface
  */
 public function isValid($value, Constraint $constraint)
 {
     if (!$value instanceof UserInterface) {
         throw new UnexpectedTypeException($value, 'FOS\\UserBundle\\Model\\UserInterface');
     }
     if (!$this->userManager->validateUnique($value, $constraint)) {
         $this->setMessage($constraint->message, array('%property%' => $constraint->property));
         return false;
     }
     return true;
 }
开发者ID:nickpro,项目名称:FOSUserBundle,代码行数:21,代码来源:UniqueValidator.php


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