當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model\UserInterface類代碼示例

本文整理匯總了PHP中Sylius\Component\User\Model\UserInterface的典型用法代碼示例。如果您正苦於以下問題:PHP UserInterface類的具體用法?PHP UserInterface怎麽用?PHP UserInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UserInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updatePassword

 /**
  * {@inheritDoc}
  */
 public function updatePassword(UserInterface $user)
 {
     if (0 !== strlen($password = $user->getPlainPassword())) {
         $user->setPassword($this->userPasswordEncoder->encode($user));
         $user->eraseCredentials();
     }
 }
開發者ID:nanyi,項目名稱:Sylius,代碼行數:10,代碼來源:PasswordUpdater.php

示例2: login

 /**
  * {@inheritDoc}
  */
 public function login(UserInterface $user, $firewallName = 'main')
 {
     if (!$user->isEnabled()) {
         return;
     }
     parent::login($user, $firewallName);
 }
開發者ID:liverbool,項目名稱:dos-user-bundle,代碼行數:10,代碼來源:UserLogin.php

示例3:

    function it_should_connect_oauth_account_with_given_user(
        $userManager,
        $oauthRepository,
        UserInterface $user,
        UserResponseInterface $response,
        ResourceOwnerInterface $resourceOwner,
        UserOAuthInterface $oauth
    ) {
        $resourceOwner->getName()->willReturn('google');

        $response->getEmail()->willReturn(null);
        $response->getUsername()->willReturn('username');
        $response->getResourceOwner()->willReturn($resourceOwner);
        $response->getAccessToken()->willReturn('access_token');

        $oauthRepository->createNew()->willReturn($oauth);

        $oauth->setIdentifier('username');
        $oauth->setProvider('google');
        $oauth->setAccessToken('access_token');

        $user->addOAuthAccount($oauth)->shouldBeCalled();

        $userManager->persist($user)->shouldBeCalled();
        $userManager->flush()->shouldBeCalled();

        $this->connect($user, $response);
    }
開發者ID:kriswillis,項目名稱:Sylius,代碼行數:28,代碼來源:UserProviderSpec.php

示例4:

 function it_does_nothing_if_plain_password_is_empty(UserPasswordEncoderInterface $userPasswordEncoder, UserInterface $user)
 {
     $user->getPlainPassword()->willReturn('');
     $userPasswordEncoder->encode($user)->willReturn('topSecretEncodedPassword');
     $user->setPassword(Argument::any())->shouldNotBeCalled();
     $user->eraseCredentials()->shouldNotBeCalled();
     $this->updatePassword($user);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:8,代碼來源:PasswordUpdaterSpec.php

示例5:

 function it_encodes_password(EncoderFactoryInterface $encoderFactory, PasswordEncoderInterface $passwordEncoder, UserInterface $user)
 {
     $user->getPlainPassword()->willReturn('topSecretPlainPassword');
     $user->getSalt()->willReturn('typicalSalt');
     $encoderFactory->getEncoder($user)->willReturn($passwordEncoder);
     $passwordEncoder->encodePassword('topSecretPlainPassword', 'typicalSalt')->willReturn('topSecretEncodedPassword');
     $this->encode($user)->shouldReturn('topSecretEncodedPassword');
 }
開發者ID:nanyi,項目名稱:Sylius,代碼行數:8,代碼來源:UserPasswordEncoderSpec.php

示例6: updatePassword

 /**
  * {@inheritDoc}
  */
 public function updatePassword(UserInterface $user)
 {
     if (0 !== strlen($password = $user->getPlainPassword())) {
         $encoder = $this->encoderFactory->getEncoder($user);
         $user->setPassword($encoder->encodePassword($password, $user->getSalt()));
         $user->eraseCredentials();
     }
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:11,代碼來源:PasswordUpdater.php

示例7:

 function it_logs_user_in($securityContext, $userChecker, $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(array('ROLE_TEST'));
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $securityContext->setToken(Argument::type('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken'))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type('Sylius\\Bundle\\UserBundle\\Event\\UserEvent'))->shouldBeCalled();
     $this->login($user);
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:8,代碼來源:UserLoginSpec.php

示例8:

 function it_logs_user_in(TokenStorageInterface $tokenStorage, UserCheckerInterface $userChecker, EventDispatcherInterface $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(['ROLE_TEST']);
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $userChecker->checkPostAuth($user)->shouldBeCalled();
     $tokenStorage->setToken(Argument::type(UsernamePasswordToken::class))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type(UserEvent::class))->shouldBeCalled();
     $this->login($user);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:9,代碼來源:UserLoginSpec.php

示例9:

 function it_logs_user_in($securityContext, $userChecker, $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(array('ROLE_TEST'));
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $userChecker->checkPostAuth($user)->shouldBeCalled();
     $securityContext->setToken(Argument::type(UsernamePasswordToken::class))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type(UserEvent::class))->shouldBeCalled();
     $this->login($user);
 }
開發者ID:Silwereth,項目名稱:Sylius,代碼行數:9,代碼來源:UserLoginSpec.php

示例10: it_does_nothing_if_plain_password_is_empty

 public function it_does_nothing_if_plain_password_is_empty($encoderFactory, PasswordEncoderInterface $encoder, UserInterface $user)
 {
     $user->getPlainPassword()->willReturn('');
     $user->getSalt()->willReturn('typicalSalt');
     $encoderFactory->getEncoder($user)->shouldNotBeCalled();
     $encoder->encodePassword('', 'typicalSalt')->shouldNotBeCalled();
     $user->setPassword(Argument::any())->shouldNotBeCalled();
     $user->eraseCredentials()->shouldNotBeCalled();
     $this->updatePassword($user);
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:10,代碼來源:PasswordUpdaterSpec.php

示例11: blame

 /**
  * @param UserInterface $user
  */
 private function blame(UserInterface $user)
 {
     $cart = $this->getCart();
     if (null === $cart) {
         return;
     }
     $cart->setCustomer($user->getCustomer());
     $this->cartManager->persist($cart);
     $this->cartManager->flush();
 }
開發者ID:okwinza,項目名稱:Sylius,代碼行數:13,代碼來源:CartBlamerListener.php

示例12:

 function it_does_not_allow_to_delete_currently_logged_user(GenericEvent $event, UserInterface $userToBeDeleted, UserInterface $currentlyLoggedInUser, $tokenStorage, $flashBag, TokenInterface $token)
 {
     $event->getSubject()->willReturn($userToBeDeleted);
     $userToBeDeleted->getId()->willReturn(1);
     $tokenStorage->getToken()->willReturn($token);
     $currentlyLoggedInUser->getId()->willReturn(1);
     $token->getUser()->willReturn($currentlyLoggedInUser);
     $event->stopPropagation()->shouldBeCalled();
     $flashBag->add('error', 'Cannot remove currently logged in user.')->shouldBeCalled();
     $this->deleteUser($event);
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:11,代碼來源:UserDeleteListenerSpec.php

示例13: array

 function it_does_not_log_user_in_if_user_was_not_found($userRepository, $session, UserInterface $user, Session $minkSession)
 {
     $userRoles = ['ROLE_USER'];
     $userRepository->findOneBy(array('username' => 'sylius@example.com'))->willReturn(null);
     $user->getRoles()->willReturn($userRoles);
     $user->getPassword()->willReturn('xyz');
     $user->serialize()->willReturn('serialized_user');
     $session->set('_security_user', Argument::any())->shouldNotBeCalled();
     $session->save()->shouldNotBeCalled();
     $session->getName()->willReturn('MOCKEDSID');
     $session->getId()->willReturn('xyzc123');
     $minkSession->setCookie('MOCKEDSID', 'xyzc123')->shouldNotBeCalled();
     $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', array('sylius@example.com', 'default', $minkSession));
 }
開發者ID:Spomky,項目名稱:Sylius,代碼行數:14,代碼來源:SecurityServiceSpec.php

示例14:

 function it_does_not_update_username_when_customer_email_is_the_same(OnFlushEventArgs $onFlushEventArgs, EntityManager $entityManager, UnitOfWork $unitOfWork, CustomerInterface $customer, UserInterface $user, ClassMetadata $userMetadata)
 {
     $onFlushEventArgs->getEntityManager()->willReturn($entityManager);
     $entityManager->getUnitOfWork()->willReturn($unitOfWork);
     $unitOfWork->getScheduledEntityInsertions()->willReturn([]);
     $unitOfWork->getScheduledEntityUpdates()->willReturn([$customer]);
     $user->getUsername()->willReturn('customer@email.com');
     $customer->getUser()->willReturn($user);
     $customer->getEmail()->willReturn('customer@email.com');
     $user->setUsername('customer@email.com')->shouldNotBeCalled();
     $entityManager->persist($user)->shouldNotBeCalled();
     $unitOfWork->recomputeSingleEntityChangeSet($userMetadata, $user)->shouldNotBeCalled();
     $this->onFlush($onFlushEventArgs);
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:14,代碼來源:DefaultUsernameORMListenerSpec.php

示例15: executeRoleCommand

 /**
  * {@inheritdoc}
  */
 protected function executeRoleCommand(OutputInterface $output, UserInterface $user, array $securityRoles)
 {
     $error = false;
     foreach ($securityRoles as $securityRole) {
         if (!$user->hasRole($securityRole)) {
             $output->writeln(sprintf('<error>User "%s" didn\'t have "%s" Security role.</error>', (string) $user, $securityRole));
             $error = true;
             continue;
         }
         $user->removeRole($securityRole);
         $output->writeln(sprintf('Security role <comment>%s</comment> has been removed from user <comment>%s</comment>', $securityRole, (string) $user));
     }
     if (!$error) {
         $this->getEntityManager()->flush();
     }
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:19,代碼來源:DemoteUserCommand.php


注:本文中的Sylius\Component\User\Model\UserInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。