本文整理匯總了PHP中Oro\Bundle\UserBundle\Entity\User::generateToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::generateToken方法的具體用法?PHP User::generateToken怎麽用?PHP User::generateToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Oro\Bundle\UserBundle\Entity\User
的用法示例。
在下文中一共展示了User::generateToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testConfirmationToken
public function testConfirmationToken()
{
$user = new User();
$token = $user->generateToken();
$this->assertNotEmpty($token);
$user->setConfirmationToken($token);
$this->assertEquals($token, $user->getConfirmationToken());
}
示例2: sendEmailAsAdminAction
/**
* @Route("/send-email-as-admin/{id}", name="oro_user_reset_send_email_as_admin", requirements={"id"="\d+"})
* @AclAncestor("password_management")
* @Template("OroUserBundle:Reset/widget:sendEmailConfirmation.html.twig")
*/
public function sendEmailAsAdminAction(User $user)
{
$params = ['entity' => $user];
if ($this->getRequest()->isMethod('POST')) {
if (null === $user->getConfirmationToken()) {
$user->setConfirmationToken($user->generateToken());
}
$this->get('session')->set(static::SESSION_EMAIL, $this->getObfuscatedEmail($user));
try {
$this->get('oro_user.mailer.processor')->sendResetPasswordAsAdminEmail($user);
} catch (\Exception $e) {
$params['processed'] = false;
$params['error'] = $this->get('translator')->trans('oro.email.handler.unable_to_send_email');
return $params;
}
$user->setPasswordRequestedAt(new \DateTime('now', new \DateTimeZone('UTC')));
$this->get('oro_user.manager')->updateUser($user);
$params['processed'] = true;
} else {
$params['formAction'] = $this->get('router')->generate('oro_user_reset_send_email_as_admin', ['id' => $user->getId()]);
}
return $params;
}