I am proficient in Drupal 7 where I get the current user object from global $user
, but how do I get it in Drupal 8 ?
如何在Drupal 8中获取当前用户对象?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- dongren4099 2017-08-23 10:15关注
Please use following code to get the current user object in Drupal 8:
$user = \Drupal::currentUser();
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报