首页 > 其他 > 详细

symfony3常用记忆

时间:2018-07-15 13:29:06      阅读:145      评论:0      收藏:0      [点我收藏+]

1、控制器里获取当前用户信息

$user = $this->getUser();

 

2、判断当前用户是否登录

// yay! Use this to see if the user is logged in
if (!$this->get(‘security.authorization_checker‘)->isGranted(‘IS_AUTHENTICATED_FULLY‘)) {
    throw $this->createAccessDeniedException();
}
// equivalent shortcut:
// $this->denyAccessUnlessGranted(‘IS_AUTHENTICATED_FULLY‘);

// boo :(. Never check for the User object to see if they‘re logged in
if ($this->getUser()) {

}

3、控制器里面重定向

$this->redirectToRoute(‘homepage‘);

 

symfony3常用记忆

原文:https://www.cnblogs.com/linxingyun/p/9313285.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!