本文整理汇总了PHP中FOS\UserBundle\Model\UserInterface::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getUsername方法的具体用法?PHP UserInterface::getUsername怎么用?PHP UserInterface::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
protected function sendMail(JournalItemEvent $itemEvent, $item, $action)
{
$journalItem = $itemEvent->getItem();
foreach ($this->ojsMailer->getJournalRelatedUsers() as $user) {
$this->ojsMailer->sendToUser($user, 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle(), 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle() . ' -> by ' . $this->user->getUsername());
}
}
示例2: sendMail
protected function sendMail(JournalItemEvent $itemEvent, $item, $action)
{
$mailUsers = $this->em->getRepository('OjsUserBundle:User')->findUsersByJournalRole(['ROLE_JOURNAL_MANAGER', 'ROLE_EDITOR']);
$journalItem = $itemEvent->getItem();
foreach ($mailUsers as $user) {
$this->ojsMailer->sendToUser($user, 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle(), 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle() . ' -> by ' . $this->user->getUsername());
}
}
示例3: sendResettingEmailMessage
/**
* {@inheritdoc}
*/
public function sendResettingEmailMessage(UserInterface $user)
{
$url = $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), true);
$subject = $this->translate('resetting.email.subject', $user->getUsername(), $url);
$body = $this->translate('resetting.email.message', $user->getUsername(), $url);
$rendered = $this->templating->render('@App/Utils/email_structure.html.twig', array('body' => $body));
$this->sendEmailMessage($rendered, $subject, $this->parameters['from_email']['resetting'], $user->getEmail());
}
示例4: onDeleteUser
public function onDeleteUser(FilterEntityEvent $event)
{
$entity = $event->getEntity();
if (!$entity instanceof UserInterface) {
return;
}
if ($this->user->getUsername() === $entity->getUsername()) {
$response = new JsonResponse(array('status' => false, 'message' => $this->translator->trans('message.cant_delete_your_self', array(), $this->container->getParameter('symfonian_id.admin.translation_domain'))));
$event->setResponse($response);
}
}
示例5: sendMail
/**
* @param UserInterface $user
* @param string $subject
* @param string $body
*/
private function sendMail(UserInterface $user, $subject, $body)
{
$message = $this->mailer->createMessage();
$to = array($user->getEmail() => $user->getUsername());
$message = $message->setSubject($subject)->addFrom($this->mailSender, $this->mailSenderName)->setTo($to)->setBody($body, 'text/html');
$this->mailer->send($message);
}
示例6: getPrincipalArray
/**
* get Array with Principal-Data from User-Object.
*
* @param UserInterface|GroupInterface $principalObject
* @param bool $show_id
*
* @return array
*
* @throws Exception
*/
private function getPrincipalArray($principalObject, $show_id = false)
{
if (!$principalObject instanceof UserInterface && !$principalObject instanceof GroupInterface) {
throw new Exception('$principalObject must be of type UserInterface of GroupInterface');
}
$principal = array();
if ($show_id) {
$principal['id'] = $principalObject->getId();
}
if ($principalObject instanceof UserInterface) {
$principal['uri'] = 'principals/' . $principalObject->getUsername();
} else {
$principal['uri'] = 'principals/' . $principalObject->getName();
}
// get all fields from $this->fieldMap, additional to 'uri' and 'id'
foreach ($this->fieldMap as $key => $value) {
if (!method_exists($principalObject, $value['getter'])) {
continue;
}
$valueGetter = call_user_func(array($principalObject, $value['getter']));
if ($valueGetter) {
$principal[$key] = $valueGetter;
}
}
return $principal;
}
示例7: updateUser
/**
* {@inheritdoc}
*/
public function updateUser(UserInterface $user, $andFlush = true)
{
// Extract email part before the `@` character to use it as username is username not set
if (null === $user->getUsername()) {
$user->setUsername(substr($user->getEmail(), 0, strpos($user->getEmail(), '@')));
}
// Call parent after as does not override parent and parent do the flush
parent::updateUser($user, $andFlush);
}
示例8: onSuccess
protected function onSuccess(UserInterface $user, $confirmation)
{
$user->setUsername($user->getUsername());
$user->setLocked(false);
$user->setEnabled(true);
$user->setCreatedAt(new \DateTime('now'));
$em = $this->container->get('doctrine.odm.mongodb.document_manager');
parent::onSuccess($user, $confirmation);
}
示例9: transform
/**
* Transforms a UserInterface instance into a username string.
*
* @param UserInterface|null $value UserInterface instance
*
* @return string|null Username
*
* @throws UnexpectedTypeException if the given value is not a UserInterface instance
*/
public function transform($value)
{
if (null === $value) {
return null;
}
if (!$value instanceof UserInterface) {
throw new UnexpectedTypeException($value, 'FOS\\UserBundle\\Model\\UserInterface');
}
return $value->getUsername();
}
示例10: SamlUser
function it_load_user_by_username(SamlAuth $auth, UserInterface $user, UserManagerInterface $userManager)
{
$auth->getAttributes()->shouldBeCalled();
$auth->getUsername()->shouldBeCalled();
$auth->isAuthenticated()->shouldBeCalled();
$user->getUsername()->shouldBeCalled();
$user->getRoles()->shouldBeCalled();
$userManager->findUserByUsername(self::USERNAME)->shouldBeCalled();
$samlUser = new SamlUser('user@domain.com', ['ROLE_USER'], []);
$this->loadUserByUsername('user@domain.com')->shouldBeLike($samlUser);
}
示例11: getQueryPagination
public function getQueryPagination(UserInterface $entity, $sort, $direction)
{
$queryBuilder = $this->createQueryBuilder('u');
$data = ['id' => $entity->getId(), 'username' => $entity->getUsername(), 'email' => $entity->getEmail(), 'enabled' => $entity->isEnabled()];
if (!empty($data['id'])) {
$queryBuilder->andWhere($queryBuilder->expr()->eq('u.id', ':id'))->setParameter('id', $data['id']);
}
if (!empty($data['username'])) {
$queryBuilder->andWhere($queryBuilder->expr()->like('u.username', ':username'))->setParameter('username', "%{$data['username']}%");
}
if (!empty($data['email'])) {
$queryBuilder->andWhere($queryBuilder->expr()->like('u.email', ':email'))->setParameter('email', "%{$data['email']}%");
}
if (!empty($data['enabled'])) {
$queryBuilder->andWhere($queryBuilder->expr()->eq('u.enabled', ':enabled'))->setParameter('enabled', $data['enabled']);
}
$queryBuilder->orderBy('u.' . $sort, $direction);
return $queryBuilder->getQuery();
}
示例12: getUsername
public function getUsername()
{
return $this->user->getUsername();
}
示例13: attachRefreshToken
/**
* Provides a refresh token.
*
* @param UserInterface $user
*
* @return string The refresh Json Web Token.
*/
protected function attachRefreshToken(UserInterface $user)
{
$refreshTokenManager = $this->container->get('gesdinet.jwtrefreshtoken.refresh_token_manager');
$refreshToken = $refreshTokenManager->getLastFromUsername($user->getUsername());
$refreshTokenTtl = $this->container->getParameter('gesdinet_jwt_refresh_token.ttl');
if (!$refreshToken instanceof RefreshToken) {
$refreshToken = $refreshTokenManager->create();
$expirationDate = new \DateTime();
$expirationDate->modify(sprintf('+%s seconds', $refreshTokenTtl));
$refreshToken->setUsername($user->getUsername());
$refreshToken->setRefreshToken();
$refreshToken->setValid($expirationDate);
$refreshTokenManager->save($refreshToken);
}
return $refreshToken->getRefreshToken();
}
示例14: updateCanonicalFields
/**
* {@inheritdoc}
*/
public function updateCanonicalFields(UserInterface $user)
{
$user->setUsernameCanonical(strtolower($user->getUsername()));
$user->setEmailCanonical(strtolower($user->getEmail()));
}
示例15: sendToUser
/**
* @param UserInterface $user
* @param string $subject
* @param string $body
*/
public function sendToUser(UserInterface $user, $subject, $body)
{
$this->send($subject, $body, $user->getEmail(), $user->getUsername());
}