【问题标题】:ZF2, doctrine and AuthenticationZF2,学说和认证
【发布时间】:2013-12-16 11:18:14
【问题描述】:

我用过学说2和ZF2。

登录系统后,我正在使用 ZF2 身份验证类 (Zend\Authentication\Authenticationservie.php) 并创建一个身份。

现在我的身份包含一些必需的用户值(这更有用并且可以获取),但是我有一个功能可以更新身份中的用户值,所以在这种情况下,我需要更新现有的实体值。否则我必须重新登录才能更新实体。

我怎样才能做到这一点? Zend\Authentication\Authenticationservie.php 中没有可用于更新现有实体的功能

【问题讨论】:

    标签: authentication zend-framework2


    【解决方案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 );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 2014-07-19
      相关资源
      最近更新 更多