/** * The initCoreVars preloads some module vars. * * Preloads module vars for a number of key modules to reduce sql statements. * * @return void */ public static function initCoreVars($force = false) { // The empty arrays for handlers and settings are required to prevent messages with E_ALL error reporting self::$modvars = new ArrayObject(array(EventUtil::HANDLERS => array(), ServiceUtil::HANDLERS => array(), 'Settings' => array())); // don't init vars during the installer or upgrader if (!$force && System::isInstalling()) { return; } // This loads all module variables into the modvars static class variable. $em = ServiceUtil::get('doctrine')->getEntityManager(); $modvars = $em->getRepository('Zikula\\Core\\Doctrine\\Entity\\ExtensionVar')->findAll(); foreach ($modvars as $var) { if (!array_key_exists($var['modname'], self::$modvars)) { self::$modvars[$var['modname']] = array(); } if (array_key_exists($var['name'], $GLOBALS['ZConfig']['System'])) { self::$modvars[$var['modname']][$var['name']] = $GLOBALS['ZConfig']['System'][$var['name']]; } else { self::$modvars[$var['modname']][$var['name']] = $var['value']; } } // Pre-load the module variables array with empty arrays for known modules that // do not define any module variables to prevent unnecessary SQL queries to // the module_vars table. $knownModules = self::getAllMods(); foreach ($knownModules as $key => $mod) { if (!array_key_exists($mod['name'], self::$modvars)) { self::$modvars[$mod['name']] = array(); } } }
/** * The initCoreVars preloads some module vars. * * Preloads module vars for a number of key modules to reduce sql statements. * * @return void */ public static function initCoreVars($force = false) { // The empty arrays for handlers and settings are required to prevent messages with E_ALL error reporting self::$modvars = new ArrayObject(array(EventUtil::HANDLERS => array(), ServiceUtil::HANDLERS => array(), 'Settings' => array())); // don't init vars during the installer or upgrader if (!$force && System::isInstalling()) { return; } // This loads all module variables into the modvars static class variable. $modvars = DBUtil::selectObjectArray('module_vars'); foreach ($modvars as $var) { if (!array_key_exists($var['modname'], self::$modvars)) { self::$modvars[$var['modname']] = array(); } if (array_key_exists($var['name'], $GLOBALS['ZConfig']['System'])) { self::$modvars[$var['modname']][$var['name']] = $GLOBALS['ZConfig']['System'][$var['name']]; } elseif ($var['value'] == '0' || $var['value'] == '1') { self::$modvars[$var['modname']][$var['name']] = $var['value']; } else { self::$modvars[$var['modname']][$var['name']] = unserialize($var['value']); } } // Pre-load the module variables array with empty arrays for known modules that // do not define any module variables to prevent unnecessary SQL queries to // the module_vars table. $knownModules = self::getAllMods(); foreach ($knownModules as $key => $mod) { if (!array_key_exists($mod['name'], self::$modvars)) { self::$modvars[$mod['name']] = array(); } } }
/** * The initCoreVars preloads some module vars. * * Preloads module vars for a number of key modules to reduce sql statements. * * @param boolean $force * * @return void */ public static function initCoreVars($force = false) { // The empty arrays for handlers and settings are required to prevent messages with E_ALL error reporting self::$modvars = new ArrayObject(array(EventUtil::HANDLERS => array(), ServiceUtil::HANDLERS => array(), 'ZikulaSettingsModule' => array())); // don't init vars during the installer or upgrader if (!$force && System::isInstalling()) { return; } // This loads all module variables into the modvars static class variable. $em = ServiceUtil::get('doctrine.entitymanager'); /** @var \Zikula\ExtensionsModule\Entity\ExtensionVarEntity[] $modvars */ $modvars = $em->getRepository('Zikula\\ExtensionsModule\\Entity\\ExtensionVarEntity')->findAll(); foreach ($modvars as $var) { if (!array_key_exists($var->getModname(), self::$modvars)) { self::$modvars[$var->getModname()] = array(); } if (array_key_exists($var->getName(), $GLOBALS['ZConfig']['System'])) { self::$modvars[$var->getModname()][$var->getName()] = $GLOBALS['ZConfig']['System'][$var->getName()]; } else { self::$modvars[$var->getModname()][$var->getName()] = $var->getValue(); } } // Init multilingual variables here, just to have values, even with default site language (page language is set later) self::setupMultilingual(); // Pre-load the module variables array with empty arrays for known modules that // do not define any module variables to prevent unnecessary SQL queries to // the module_vars table. $knownModules = self::getAllMods(); foreach ($knownModules as $key => $mod) { if (!array_key_exists($mod['name'], self::$modvars)) { self::$modvars[$mod['name']] = array(); } } }