Created
November 10, 2012 01:06
-
-
Save SocalNick/4049346 to your computer and use it in GitHub Desktop.
Initialize Session Oddity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application; | |
use Zend\ModuleManager\ModuleManager; | |
use Zend\Mvc\ModuleRouteListener; | |
use Zend\Mvc\MvcEvent; | |
class Module | |
{ | |
public function getAutoloaderConfig() | |
{ | |
return array( | |
'Zend\Loader\ClassMapAutoloader' => array( | |
__DIR__ . '/autoload_classmap.php', | |
), | |
'Zend\Loader\StandardAutoloader' => array( | |
'namespaces' => array( | |
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, | |
), | |
), | |
); | |
} | |
public function getConfig() | |
{ | |
return include __DIR__ . '/config/module.config.php'; | |
} | |
public function getServiceConfig() | |
{ | |
return array( | |
'factories' => array( | |
'Zend\Session\SessionManager' => function($sm) { | |
return new \Zend\Session\SessionManager(); | |
}, | |
), | |
); | |
} | |
public function onBootstrap(MvcEvent $e) | |
{ | |
$this->initSession($e); | |
} | |
// DOES NOT WORK | |
public function initSession($e) | |
{ | |
$app = $e->getApplication(); | |
$serviceManager = $app->getServiceManager(); | |
$session = $serviceManager->get('Zend\Session\SessionManager'); | |
$session->setName('IGNPHANTOM'); | |
} | |
// WORKS | |
public function initSession($e) | |
{ | |
$session = new \Zend\Session\SessionManager(); | |
$session->setName('IGNPHANTOM'); | |
} | |
} |
fyi; you may want to also set the default manager to the Container, this should solve the Zend\Authenticate issue since it attempts to create a container on your behalf:
public function initSession($e)
{
$session = new \Zend\Session\SessionManager();
$session->setName('IGNPHANTOM');
\Zend\Session\Container::setDefaultManager($session);
}
Still looking into why the session manager is borked when you're using a service factory...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is REALLY odd. I'm actually baffled here.