简体   繁体   中英

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. Would like to get the current logged in user from EzPlatform to my symfony controller using php.

Any ideas how to do that?

If you need the Symfony user, you can get it from token storage service ( @security.token_storage ):

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

Once you have the Symfony user, you can get eZ Platform user with:

$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:

$eZUser = $repository->getCurrentUser();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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