/** * Singleton function used to manage this object. * * @param bool $loadFromDB * whether to load from the database. * @param bool $force * whether to force a reconstruction. * * @return CRM_Core_Config */ public static function &singleton($loadFromDB = TRUE, $force = FALSE) { if (self::$_singleton === NULL || $force) { $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle')); $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler')); if (defined('E_DEPRECATED')) { error_reporting(error_reporting() & ~E_DEPRECATED); } self::$_singleton = new CRM_Core_Config(); \Civi\Core\Container::boot($loadFromDB); if ($loadFromDB && self::$_singleton->dsn) { $domain = \CRM_Core_BAO_Domain::getDomain(); \CRM_Core_BAO_ConfigSetting::applyLocale(\Civi::settings($domain->id), $domain->locales); unset($errorScope); CRM_Utils_Hook::config(self::$_singleton); self::$_singleton->authenticate(); // Extreme backward compat: $config binds to active domain at moment of setup. self::$_singleton->getSettings(); Civi::service('settings_manager')->useDefaults(); self::$_singleton->handleFirstRun(); } } return self::$_singleton; }
/** * Retrieve the settings values from db. * * @param $defaults * * @return array */ public static function retrieve(&$defaults) { $domain = new CRM_Core_DAO_Domain(); //we are initializing config, really can't use, CRM-7863 $urlVar = 'q'; if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') { $urlVar = 'task'; } if (CRM_Core_Config::isUpgradeMode()) { $domain->selectAdd('config_backend'); } else { $domain->selectAdd('config_backend, locales'); } $domain->id = CRM_Core_Config::domainID(); $domain->find(TRUE); if ($domain->config_backend) { $defaults = unserialize($domain->config_backend); if ($defaults === FALSE || !is_array($defaults)) { $defaults = array(); return FALSE; } $skipVars = self::skipVars(); foreach ($skipVars as $skip) { if (array_key_exists($skip, $defaults)) { unset($defaults[$skip]); } } CRM_Core_BAO_ConfigSetting::applyLocale(Civi::settings($domain->id), $domain->locales); } }