本文整理汇总了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();
}
}
示例2: login
/**
* {@inheritDoc}
*/
public function login(UserInterface $user, $firewallName = 'main')
{
if (!$user->isEnabled()) {
return;
}
parent::login($user, $firewallName);
}
示例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);
}
示例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);
}
示例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');
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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));
}
示例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);
}
示例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();
}
}