简体   繁体   English

如何使用php将当前登录的用户从EzPlatform 1.1转换为symfony类代码?

[英]How to get current logged in user from EzPlatform 1.1 to symfony class code using php?

I'm developing web application with symfony and also using EzPlatform as Cms for the same project. 我正在使用symfony开发Web应用程序,并且还在同一项目中使用EzPlatform作为Cms。 Would like to get the current logged in user from EzPlatform to my symfony controller using php. 想要使用php将当前登录的用户从EzPlatform获取到我的symfony控制器。

Any ideas how to do that? 任何想法如何做到这一点?

If you need the Symfony user, you can get it from token storage service ( @security.token_storage ): 如果需要Symfony用户,可以从令牌存储服务( @security.token_storage )获取它:

$sfUser = $tokenStorage->getToken()->getUser();

Once you have the Symfony user, you can get eZ Platform user with: 拥有Symfony用户后,您可以通过以下方式获取eZ Platform用户:

$eZUser = $sfUser->getAPIUser();

There is also a method called getCurrentUser on eZ repository ( @ezpublish.api.repository service) with which you can get the current user directly: eZ存储库( @ezpublish.api.repository服务)上还有一个名为getCurrentUser的方法,您可以使用该方法直接获取当前用户:

$eZUser = $repository->getCurrentUser();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM