我使用过教义2和ZF2。
登录系统后,我正在使用ZF2身份验证类(Zend\Authentication\Authenticationservie.php
)并创建一个身份。
现在我的标识包含一些必需的用户值(这是更有用并且可以获取),但是我有一个功能可以更新同样具有标识的用户值,所以在这种情况下我需要更新现有的实体值。否则我必须重新登录以更新实体。
我怎样才能做到这一点?没有可用于更新Zend\Authentication\Authenticationservie.php
答案 0 :(得分:1)
ZF2认证服务使用存储容器,存储标识数据。您可以使用$this->getStorage()->write( $myData )
所以你用这样的东西更新身份
// benutzer entity update
$benutzer->setSomeMethodSetTo('newValue');
// doctrine update
$entityManager->persist( $benutzer );
$entityManager->flush();
// write updated benutzer to
$authService = $this->getServiceManager()->get('Zend\Authentication\Authentication');
$authService->getStorage()->write( $benutzer );