本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getUsername方法的具体用法?PHP UserInterface::getUsername怎么用?PHP UserInterface::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\User\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthorName
public function getAuthorName()
{
if (null === $this->author) {
return $this->author_name;
}
return $this->author->getUsername();
}
示例2: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(['data_class' => RequestRememberPasswordCommand::class, 'empty_data' => function (FormInterface $form) {
$email = null === $this->currentUser ? $form->get('email')->getData() : $this->currentUser->getUsername();
return new RequestRememberPasswordCommand($email);
}]);
}
示例3: bind
/**
* {@inheritDoc}
*
* @uses connect()
*
* @throws LdapDriverException
*/
public function bind(UserInterface $user, $password)
{
if ($user instanceof LdapUserInterface && $user->getDn()) {
$bind_rdn = $user->getDn();
} elseif (isset($this->params['bindRequiresDn']) && $this->params['bindRequiresDn']) {
if (!isset($this->params['baseDn']) || !isset($this->params['accountFilterFormat'])) {
throw new LdapDriverException('Param baseDn and accountFilterFormat is required if bindRequiresDn is true');
}
$bind_rdn = $this->search($this->params['baseDn'], sprintf($this->params['accountFilterFormat'], $user->getUsername()));
if (1 == $bind_rdn['count']) {
$bind_rdn = $bind_rdn[0]['dn'];
} else {
return false;
}
} else {
$bind_rdn = $user->getUsername();
}
if (null === $this->ldap_res) {
$this->connect();
}
$this->logDebug(sprintf('ldap_bind(%s, ****)', $bind_rdn));
ErrorHandler::start(E_WARNING);
$bind = ldap_bind($this->ldap_res, $bind_rdn, $password);
ErrorHandler::stop();
return $bind;
}
示例4: createUser
/**
* Adds a new User to the provider.
*
* @param UserInterface $user A UserInterface instance
*
* @throws \LogicException
*/
public function createUser(UserInterface $user)
{
if (isset($this->users[strtolower($user->getUsername())])) {
throw new \LogicException('Another user with the same username already exists.');
}
$this->users[strtolower($user->getUsername())] = $user;
}
示例5: refreshUser
/**
* {@inheritDoc}
*/
public function refreshUser(UserInterface $user)
{
if (null === ($refreshedUser = $this->repository->findOneByUsername($user->getUsername()))) {
throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($user->getId())));
}
return $refreshedUser;
}
示例6: equals
/**
* @inheritdoc
*/
public function equals(UserInterface $user)
{
if (!$user instanceof User) {
return false;
}
return $user->getUsername() === $this->username;
}
示例7: isEqualTo
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof CorredorUser || $this->password !== $user->getPassword() || $this->salt !== $user->getSalt() || $this->username !== $user->getUsername()) {
return false;
}
return true;
}
示例8: isEqualTo
public function isEqualTo(UserInterface $user)
{
if ($this->username == $user->getUsername()) {
return true;
}
return false;
}
示例9: refreshUser
public function refreshUser(UserInterface $user)
{
if (!$user instanceof User) {
throw new UnsupportedUserException("Instances of {get_class({$user})} are not supported");
}
return $this->loadUserByUsername($user->getUsername());
}
示例10: equals
public function equals(UserInterface $user)
{
if ($user instanceof MagentoUser) {
return $user->getId() === $user->id;
}
return $user->getUsername() === $this->email;
}
示例11: isEqualTo
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof LdapUser || $user->getUsername() !== $this->username || $user->getEmail() !== $this->email || count(array_diff($user->getRoles(), $this->roles)) > 0 || $user->getDn() !== $this->dn) {
return false;
}
return true;
}
示例12: equals
public function equals(UserInterface $account)
{
if ($this->getUsername() == $account->getUsername()) {
return true;
}
return false;
}
示例13: refreshUser
public function refreshUser(UserInterface $user)
{
if ($user instanceof User) {
return $this->loadUserByUsername($user->getUsername());
}
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}
示例14: refreshUser
/**
* Refresh the User object
* @param UserInterface $user
* @return UserInterface
*/
public function refreshUser(UserInterface $user)
{
try {
return $this->loadUserByUsername($user->getUsername());
} catch (UsernameNotFoundException $e) {
throw new UnsupportedUserException(sprintf('User "%s" did not come from this provider (%s).', $user->getUsername(), get_called_class()));
}
}
示例15: processRecord
/**
* @param array $record
*
* @return array
*/
public function processRecord(array $record)
{
if (is_null($this->user)) {
/* @var TokenStorageInterface $securityTokenStorage */
$securityTokenStorage = $this->container->get('security.token_storage');
if ($securityTokenStorage !== null && $securityTokenStorage->getToken() !== null && $securityTokenStorage->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
$this->user = $securityTokenStorage->getToken()->getUser();
$this->record['extra']['user']['username'] = $this->user->getUsername();
$this->record['extra']['user']['roles'] = $this->user->getRoles();
$this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
$this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
$this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
$this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
}
}
return array_merge($record, $this->record);
}