/** * Factory for AuthManager. * * @param ServiceManager $sm Service manager. * * @return Manager */ public static function getAuthManager(ServiceManager $sm) { $config = $sm->get('VuFind\\Config')->get('config'); try { // Check if the catalog wants to hide the login link, and override // the configuration if necessary. $catalog = $sm->get('VuFind\\ILSConnection'); if ($catalog->loginIsHidden()) { $config = new \Zend\Config\Config($config->toArray(), true); $config->Authentication->hideLogin = true; $config->setReadOnly(); } } catch (\Exception $e) { // Ignore exceptions; if the catalog is broken, throwing an exception // here may interfere with UI rendering. If we ignore it now, it will // still get handled appropriately later in processing. error_log($e->getMessage()); } // Load remaining dependencies: $userTable = $sm->get('VuFind\\DbTablePluginManager')->get('user'); $sessionManager = $sm->get('VuFind\\SessionManager'); $pm = $sm->get('VuFind\\AuthPluginManager'); $cookieManager = $sm->get('VuFind\\CookieManager'); // Build the object: return new Manager($config, $userTable, $sessionManager, $pm, $cookieManager); }
public function getConfig() { /* init config object */ $config = new \Zend\Config\Config(include 'Module.config.php'); /* autoload module configs */ $dir = $this->_module_dir; $list = scandir($dir); foreach ($list as $item) { if ($item != '.' && $item != '..') { $file = $dir . '/' . $item . '/Config.php'; if (file_exists($file)) { $config->merge(new \Zend\Config\Config(include $file)); } } } /* autoload source module configs */ $dir = $this->_source_dir; if (is_dir($dir)) { $list = scandir($dir); foreach ($list as $item) { if ($item != '.' && $item != '..') { $file = $dir . '/' . $item . '/Config.php'; if (file_exists($file)) { $config->merge(new \Zend\Config\Config(include $file)); } } } } /* return merged module config */ return $config->toArray(); }
protected function getApplicationServiceManager(array $configuration = array()) { $config = new \Zend\Config\Config(include __DIR__ . '/../../test.config.php'); $config->merge(new \Zend\Config\Config($this->defaultApplicationConfig)); $config->merge(new \Zend\Config\Config($configuration)); $serviceManager = new ServiceManager(new ServiceManagerConfig($config->toArray())); $serviceManager->setService('ApplicationConfig', $config); $serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory'); /* @var $moduleManager \Zend\ModuleManager\ModuleManagerInterface */ $moduleManager = $serviceManager->get('ModuleManager'); $moduleManager->loadModules(); return $serviceManager; }
<?php $config = array('di' => array('instance' => array('alias' => array('user' => 'User\\Controller\\UserController'), 'Zend\\Db\\Adapter\\PdoMysql' => array('parameters' => array('config' => array('host' => 'changeme', 'dbname' => 'changeme', 'username' => 'changeme', 'password' => 'changeme', 'charset' => 'UTF8'))), 'User\\Service\\User' => array('parameters' => array('userMapper' => 'User\\Model\\Mapper\\User', 'registerForm' => 'User\\Form\\Register', 'loginForm' => 'User\\Form\\Login', 'auth' => 'Zend\\Authentication\\AuthenticationService')), 'User\\Model\\Mapper\\User' => array('parameters' => array('readAdapter' => 'Zend\\Db\\Adapter\\PdoMysql', 'writeAdapter' => 'Zend\\Db\\Adapter\\PdoMysql')), 'User\\Form\\Register' => array('parameters' => array('userMapper' => 'User\\Model\\Mapper\\User')), 'User\\Controller\\UserController' => array('parameters' => array('router' => 'Zf2Mvc\\Router\\SimpleRouteStack', 'userService' => 'User\\Service\\User')), 'Zend\\View\\PhpRenderer' => array('methods' => array('setResolver' => array('options' => array('script_paths' => array('user' => __DIR__ . '/../views')))))))); if (file_exists(__DIR__ . '/config.' . APPLICATION_ENV . '.php')) { $config = new Zend\Config\Config($config, true); $config->merge(new Zend\Config\Config(include __DIR__ . '/config.' . APPLICATION_ENV . '.php')); return $config->toArray(); } return $config;
public function getModuleConfig($moduleName) { $configKey = ucfirst($moduleName); if (isset($this->moduleConfig[$configKey])) { return $this->moduleConfig[$configKey]; } $modulePath = $this->getModulePath($moduleName); if (!$modulePath) { return $this->moduleConfig[$configKey] = array(); } $path = $modulePath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR; $globalConfig = $path . 'module.global.config.php'; $localConfig = $path . 'module.local.config.php'; if (false === file_exists($globalConfig)) { return $this->moduleConfig[$configKey] = array(); } if (!file_exists($localConfig)) { return $this->moduleConfig[$configKey] = (include $globalConfig); } $globalConfig = new \Zend\Config\Config(include $globalConfig); $localConfig = new \Zend\Config\Config(include $localConfig); $globalConfig->merge($localConfig); return $this->moduleConfig[$configKey] = $globalConfig->toArray(); }