PHP / Apigility | Fórum | School of Net

Deseja poder participar de nosso fórum e tirar todas as suas dúvidas?
Clique aqui e assine nosso plano de acesso ilimitado. Saiba mais.

por Natália

2 meses, 1 semana atrás Natália

PHP / Apigility

Boa Noite. Trabalhando com o OAuth2 eu fazia: ``` $user = $this->getIdentity(); $identity = $user->getAuthenticationIdentity(); ``` E pronto, agora trabalhando com Oauth2-doctrine tenho: ``` "user": { "user": { "__initializer__": null, "__cloner__": null, "__isInitialized__": true }, "client": { "__initializer__": null, "__cloner__": null, "__isInitialized__": true }, "accessToken": {}, ``` Que vem de um array: ``` $identity = {array} [3] user = {DoctrineORMModule\Proxy\__CG__\Heimdall\V1\Entity\User} [14] lazyPropertiesDefaults = {array} [0] __initializer__ = null __cloner__ = null __isInitialized__ = true *Heimdall\V1\Entity\User*id = 1 *Heimdall\V1\Entity\User*username = "johndoe" *Heimdall\V1\Entity\User*firstName = "John" *Heimdall\V1\Entity\User*lastName = "Doe" *Heimdall\V1\Entity\User*password = "$2y$10$x.ekqRey0vcD4y9QM4.vx.iPiFBYnGAAD7sRKzeKNeCG5iXKkFOie" *Heimdall\V1\Entity\User*role = {DoctrineORMModule\Proxy\__CG__\Heimdall\V1\Entity\AclRole} [7] *Heimdall\V1\Entity\User*accessToken = {Doctrine\ORM\PersistentCollection} [9] *Heimdall\V1\Entity\User*authorizationCode = {Doctrine\ORM\PersistentCollection} [9] *Heimdall\V1\Entity\User*refreshToken = {Doctrine\ORM\PersistentCollection} [9] *Heimdall\V1\Entity\User*client = {Doctrine\ORM\PersistentCollection} [9] client = {DoctrineORMModule\Proxy\__CG__\ZF\OAuth2\Doctrine\Entity\Client} [18] lazyPropertiesDefaults = {array} [0] __initializer__ = null __cloner__ = null __isInitialized__ = true *ZF\OAuth2\Doctrine\Entity\Client*clientId = "testclient" *ZF\OAuth2\Doctrine\Entity\Client*secret = "$2y$10$Qk07KeMJ7aZXAH096KPzreERmWsgjjnXayYPrq3pzA9aIdG1AxLT." *ZF\OAuth2\Doctrine\Entity\Client*redirectUri = "/oauth/receivecode" *ZF\OAuth2\Doctrine\Entity\Client*grantType = {array} [1] *ZF\OAuth2\Doctrine\Entity\Client*clientScope = null *ZF\OAuth2\Doctrine\Entity\Client*id = "2" *ZF\OAuth2\Doctrine\Entity\Client*accessToken = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*refreshToken = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*authorizationCode = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*jwt = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*jti = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*publicKey = null *ZF\OAuth2\Doctrine\Entity\Client*scope = {Doctrine\ORM\PersistentCollection} [9] *ZF\OAuth2\Doctrine\Entity\Client*user = null accessToken = {ZF\OAuth2\Doctrine\Entity\AccessToken} [6] accessToken = "f2f9f9971821f1d6d5123dced863e0daa5c380da" expires = {DateTime} [3] id = "12" client = {DoctrineORMModule\Proxy\__CG__\ZF\OAuth2\Doctrine\Entity\Client} [18] scope = {Doctrine\ORM\PersistentCollection} [9] user = {DoctrineORMModule\Proxy\__CG__\Heimdall\V1\Entity\User} [14] $now = "08/01/2019 23:39:41" $time = "31/12/1969 23:00:00" ``` Minha dúvida é se existe um plugin para facilitar a captura dos dados de usuário logado. No caso que facilite: ``` $user = $this->getIdentity(); $identity = $user->getAuthenticationIdentity(); $idn = $identity['user']; $u = $idn->getUsername(); ``` Estou achando um caminho longo de+ para algo que deveria ter acesso com um $this->user-> ``` $identity = {array} [3] user = {DoctrineORMModule\Proxy\__CG__\Heimdall\V1\Entity\User} [14] client = {DoctrineORMModule\Proxy\__CG__\ZF\OAuth2\Doctrine\Entity\Client} [18] accessToken = {ZF\OAuth2\Doctrine\Entity\AccessToken} [6] ``` Estou querendo saber se estou escrevendo cod d+. Obrigada.

10 Respostas