Skip to content
Snippets Groups Projects
Commit 65d21223 authored by Demian Katz's avatar Demian Katz
Browse files

Replaced explicit object construction in Bootstrap class with service manager configuration.

parent 196f2f04
No related merge requests found
...@@ -100,6 +100,12 @@ $config = array( ...@@ -100,6 +100,12 @@ $config = array(
'result-scroller' => 'VuFind\Controller\Plugin\ResultScroller', 'result-scroller' => 'VuFind\Controller\Plugin\ResultScroller',
) )
), ),
'service_manager' => array(
'invokables' => array(
'authmanager' => 'VuFind\Auth\Manager',
'sessionmanager' => 'Zend\Session\SessionManager',
)
),
'translator' => array(), 'translator' => array(),
'view_manager' => array( 'view_manager' => array(
'display_not_found_reason' => APPLICATION_ENV == 'development', 'display_not_found_reason' => APPLICATION_ENV == 'development',
......
...@@ -26,13 +26,12 @@ ...@@ -26,13 +26,12 @@
* @link http://vufind.org Main Site * @link http://vufind.org Main Site
*/ */
namespace VuFind; namespace VuFind;
use VuFind\Auth\Manager as AuthManager, VuFind\Config\Reader as ConfigReader, use VuFind\Config\Reader as ConfigReader,
VuFind\Db\AdapterFactory as DbAdapterFactory, VuFind\Logger, VuFind\Db\AdapterFactory as DbAdapterFactory, VuFind\Logger,
VuFind\Theme\Initializer as ThemeInitializer, VuFind\Theme\Initializer as ThemeInitializer,
VuFind\Translator\Translator, Zend\Console\Console, VuFind\Translator\Translator, Zend\Console\Console,
Zend\Db\TableGateway\Feature\GlobalAdapterFeature as DbGlobalAdapter, Zend\Db\TableGateway\Feature\GlobalAdapterFeature as DbGlobalAdapter,
Zend\Mvc\MvcEvent, Zend\Mvc\Router\Http\RouteMatch, Zend\Mvc\MvcEvent, Zend\Mvc\Router\Http\RouteMatch;
Zend\Session\SessionManager;
/** /**
* VuFind Bootstrapper * VuFind Bootstrapper
...@@ -107,9 +106,8 @@ class Bootstrap ...@@ -107,9 +106,8 @@ class Bootstrap
} }
// Register a session manager in the service manager: // Register a session manager in the service manager:
$sessionManager = new SessionManager();
$serviceManager = $this->event->getApplication()->getServiceManager(); $serviceManager = $this->event->getApplication()->getServiceManager();
$serviceManager->setService('SessionManager', $sessionManager); $sessionManager = $serviceManager->get('SessionManager');
// Set up session handler (after manipulating the type setting for legacy // Set up session handler (after manipulating the type setting for legacy
// compatibility -- VuFind 1.x used MySQL instead of Database and had // compatibility -- VuFind 1.x used MySQL instead of Database and had
...@@ -178,17 +176,11 @@ class Bootstrap ...@@ -178,17 +176,11 @@ class Bootstrap
*/ */
protected function initAccount() protected function initAccount()
{ {
$authManager = new AuthManager(); // Retrieve from service manager:
// Register in service manager:
$serviceManager = $this->event->getApplication()->getServiceManager(); $serviceManager = $this->event->getApplication()->getServiceManager();
$serviceManager->setService('AuthManager', $authManager); $authManager = $serviceManager->get('AuthManager');
// ...and register service manager in AuthManager (for access to other
// services, such as the session manager):
$authManager->setServiceLocator($serviceManager);
// Now that we're all set up, make sure credentials haven't expired: // Make sure credentials haven't expired:
$authManager->checkForExpiredCredentials(); $authManager->checkForExpiredCredentials();
// Register in view: // Register in view:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment