當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。