Iḿ using ZF3 and I'm building a service that will provide application wide segmented access to the application session container. This service is called SessionContainerManager and will have methods to retrieve and update user identity, user ACLs, etc. My code:
namespace User\Service;
class SessionContainerManager
{
/**
* Service container.
* @var Zend\Service\Container
*/
private $sessionContainer;
public function __construct($sessionContainer)
{
$this->sessionContainer = $sessionContainer;
}
public function getACLList()
{
return $this->sessionContainer->aclList;
}
public function setACLList($aclList)
{
$this->sessionContainer->aclList = $aclList;
}
public function getIdentity()
{
return $this->sessionContainer->identity;
}
public function setIdentity($identity)
{
$this->sessionContainer->identity = $identity;
}
}
And its factory:
namespace User\Service\Factory;
use Interop\Container\ContainerInterface;
use User\Service\SessionContainerManager;
use Zend\Session\Container;
class SessionContainerManagerFactory
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$sessionContainer = $container->get(\Zend\Session\Container::class);
return new SessionContainerManager($sessionContainer);
}
}
In module.config:
'service_manager' => [
'factories' => [
Service\SessionContainerManager::class => Service\Factory\SessionContainerManagerFactory::class,
],
When running the app I'm getting the following error:
File:
/home/renato/project/dev/fways/php/fways/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:670
Message:
Unable to resolve service "Zend\Session\Container" to a factory; are you certain you provided it during configuration?
Help appreciated to make this session container to work.