我正在研究 ZF2,并且我已经开发了自己的身份验证存储,但我想知道如何添加新的持久变量(类似会话)。
查看我的身份验证存储:
<?php
namespace Application\Model;
use Zend\Authentication\Storage;
use Zend\Authentication\Storage\StorageInterface;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceManager;
use Application\Model\User;
class MyAuthStorage implements Storage\StorageInterface, ServiceManagerAwareInterface
{
protected $storage;
protected $userTable;
protected $resolvedIdentity;
protected $serviceManager;
public function isEmpty() {
[...]
}
public function read() {
[...]
}
public function write($contents) {
[...]
}
public function clear() {
[...]
}
public function getStorage() {
[...]
}
public function setStorage(Storage\StorageInterface $storage) {
[...]
}
public function getUserTable() {
[...]
}
public function getServiceManager() {
[...]
}
public function setServiceManager(ServiceManager $serviceManager) {
[...]
}
}
我想在我的存储中添加一个名为foo的变量(我的会话?)
我试试这个,但它不起作用:
protected $foo;
public function setFoo($value) {
$this->foo= $value;
}
public function getFoo() {
return $this->foo;
}
有任何想法吗 ?