protected function getApplicationConfig(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)); return $config; }
/** * 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(); }
public function getConfig() { // Required to be defined value used in include config files. $module = $this->namespace; $module_dir = $this->dir; $config = (include "{$module_dir}/config/module.config.php"); if (defined('MY_LIBRARY_PATH') and file_exists(MY_LIBRARY_PATH . '/config/module.common.config.php')) { $common_config = (include MY_LIBRARY_PATH . '/config/module.common.config.php'); $cc_object = new \Zend\Config\Config($common_config); $c_object = new \Zend\Config\Config($config); $merged_config = $c_object->merge($cc_object)->toArray(); return $merged_config; } return $config; }
/** * This function returns the value of a parameter from the configuration file * * WARNING - this function relies heavily on global variables $updateFromConfigFile * and $configFile, and also changes these globals. This can be rewritten. * * @param string $param the parameter of which the value is returned * @param string If we want to give the path rather than take it from POST * @return string the value of the parameter * @author Olivier Brouckaert * @author Reworked by Ivan Tcholakov, 2010 */ function get_config_param($param, $updatePath = '') { global $configFile, $updateFromConfigFile; // Look if we already have the queried parameter. if (is_array($configFile) && isset($configFile[$param])) { return $configFile[$param]; } if (empty($updatePath) && !empty($_POST['updatePath'])) { $updatePath = $_POST['updatePath']; } if (empty($updatePath)) { $updatePath = api_get_path(SYS_PATH); } $updatePath = api_add_trailing_slash(str_replace('\\', '/', realpath($updatePath))); $updateFromInstalledVersionFile = ''; if (empty($updateFromConfigFile)) { // If update from previous install was requested, // try to recover config file from Chamilo 1.9.x if (file_exists($updatePath . 'main/inc/conf/configuration.php')) { $updateFromConfigFile = 'main/inc/conf/configuration.php'; } else { // Give up recovering. //error_log('Chamilo Notice: Could not find previous config file at '.$updatePath.'main/inc/conf/configuration.php nor at '.$updatePath.'claroline/inc/conf/claro_main.conf.php in get_config_param(). Will start new config (in '.__FILE__.', line '.__LINE__.')', 0); return null; } } if (file_exists($updatePath . $updateFromConfigFile) && !is_dir($updatePath . $updateFromConfigFile)) { require $updatePath . $updateFromConfigFile; $config = new Zend\Config\Config($_configuration); return $config->get($param); } error_log('Config array could not be found in get_config_param()', 0); return null; /*if (file_exists($updatePath.$updateFromConfigFile)) { return $val; } else { error_log('Config array could not be found in get_config_param()', 0); return null; }*/ }
protected function getCircuitBreaker($config = array()) { $commandConfig = new \Zend\Config\Config(array('circuitBreaker' => array('enabled' => true, 'errorThresholdPercentage' => 50, 'forceOpen' => false, 'forceClosed' => false, 'requestVolumeThreshold' => 50, 'sleepWindowInMilliseconds' => 5000, 'metrics' => array('healthSnapshotIntervalInMilliseconds' => 1000, 'rollingStatisticalWindowInMilliseconds' => 10000, 'rollingStatisticalWindowBuckets' => 10))), true); $commandConfig->merge(new \Zend\Config\Config($config, true)); return new CircuitBreaker('TestCommand', $this->metrics, $commandConfig, $this->stateStorage); }
<?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(); }