本文整理汇总了PHP中Mage_Core_Model_Config_Base::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Config_Base::loadFile方法的具体用法?PHP Mage_Core_Model_Config_Base::loadFile怎么用?PHP Mage_Core_Model_Config_Base::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Config_Base
的用法示例。
在下文中一共展示了Mage_Core_Model_Config_Base::loadFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extendConfig
/**
* Extend extra configs from etc folder of module on system init configs
*
* @param Varien_Event_Observer $observer
*/
public function extendConfig($observer)
{
$storeCode = Mage::helper("jmbasetheme")->getCurrentStoreCode("backend");
$profiles = array_keys(Mage::helper("jmbasetheme")->getProfiles($storeCode));
$mergeObject = new Mage_Core_Model_Config_Base();
$profilePath = Mage::helper("jmbasetheme")->getProfilePath($storeCode);
foreach ($profiles as $profile) {
if (file_exists($profilePath . "core" . DS . $profile . ".xml")) {
$mergeObject->loadFile($profilePath . "core" . DS . $profile . ".xml");
} else {
$mergeObject->loadFile($profilePath . "local" . DS . $profile . ".xml");
}
$observer->config->extend($mergeObject, false);
}
if (file_exists($profilePath . "core" . DS . "core.xml")) {
$mergeObject->loadFile($profilePath . "core" . DS . "core.xml");
$observer->config->extend($mergeObject, false);
}
//extend tablet settings
$mergeObject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/device.xml");
$observer->config->extend($mergeObject, false);
//extend mobile settings
$mergeObject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/mobile.xml");
$observer->config->extend($mergeObject, false);
}
示例2: addMageOneFourConfig
public function addMageOneFourConfig($observer)
{
if (version_compare(Mage::getVersion(), '1.5.0.0', '<')) {
$file = Mage::getModuleDir('etc', 'MageBase_DpsPaymentExpress') . DS . 'config-1.4.xml';
$config = Mage::getConfig();
$prototype = new Mage_Core_Model_Config_Base();
$prototype->loadFile($file);
$config->extend($prototype);
$config->saveCache();
}
}
示例3: loadModules
public function loadModules(array $files)
{
$this->loadString('<config/>');
$loadedModules = array();
foreach ($files as $file) {
$this->_magento2config->loadFile($file);
$moduleName = $this->_magento2config->getNode('module')->getAttribute('name');
if ($this->isModuleLoaded($moduleName)) {
$loadedModules[] = $moduleName;
continue;
}
$loadedModules[] = $moduleName;
$version = $this->_magento2config->getNode('module')->getAttribute('schema_version');
$modules = Mage::getConfig()->getNode('modules');
$child = $modules->addChild($moduleName);
$child->addChild('active', 'true');
$child->addChild('codePool', 'community');
$child->addChild('version', $version);
$this->loadString('<config/>');
}
return $loadedModules;
}
示例4: Extendconfig
public function Extendconfig($observer)
{
$profiles = array_keys(Mage::helper("jmbasetheme")->getProfiles());
$mergeobject = new Mage_Core_Model_Config_Base();
foreach ($profiles as $profile) {
if (file_exists(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . $profile . ".xml")) {
$mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . $profile . ".xml");
} else {
$mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "local" . DS . $profile . ".xml");
}
$observer->config->extend($mergeobject, false);
}
if (file_exists(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . "core.xml")) {
$mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . "core.xml");
$observer->config->extend($mergeobject, false);
}
//extend tablet settings
$mergeobject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/device.xml");
$observer->config->extend($mergeobject, false);
//extend mobile settings
$mergeobject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/mobile.xml");
$observer->config->extend($mergeobject, false);
}
示例5: _initSectionsAndTabs
protected function _initSectionsAndTabs()
{
if (Mage::helper('advanced')->isAnyStoreDisabled()) {
$mergeConfig = Mage::getModel('core/config_base');
$config = Mage::getConfig()->loadModulesConfiguration('system.xml');
//these 4 lines are the only added content
$configFile = Mage::helper('advanced')->getEtcPath() . DS . 'system-disabled.xml';
$mergeModel = new Mage_Core_Model_Config_Base();
$mergeModel->loadFile($configFile);
$config = $config->extend($mergeModel, true);
$this->_sections = $config->getNode('sections');
$this->_tabs = $config->getNode('tabs');
} else {
return parent::_initSectionsAndTabs();
}
return parent::_initSectionsAndTabs();
}
示例6: _loadDeclaredModules
/**
* Load declared modules configuration
*
* @param null $mergeConfig depricated
* @return Mage_Core_Model_Config
*/
protected function _loadDeclaredModules($mergeConfig = null)
{
$moduleFiles = $this->_getDeclaredModuleFiles();
if (!$moduleFiles) {
return;
}
Varien_Profiler::start('config/load-modules-declaration');
$unsortedConfig = new Mage_Core_Model_Config_Base();
$unsortedConfig->loadString('<config/>');
$fileConfig = new Mage_Core_Model_Config_Base();
// load modules declarations
foreach ($moduleFiles as $file) {
$fileConfig->loadFile($file);
$unsortedConfig->extend($fileConfig);
}
$moduleDepends = array();
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
if (!$this->_isAllowedModule($moduleName)) {
continue;
}
$depends = array();
if ($moduleNode->depends) {
foreach ($moduleNode->depends->children() as $depend) {
$depends[$depend->getName()] = true;
}
}
$moduleDepends[$moduleName] = array('module' => $moduleName, 'depends' => $depends, 'active' => 'true' === (string) $moduleNode->active ? true : false);
}
// check and sort module dependence
$moduleDepends = $this->_sortModuleDepends($moduleDepends);
// create sorted config
$sortedConfig = new Mage_Core_Model_Config_Base();
$sortedConfig->loadString('<config><modules/></config>');
foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) {
if ($nodeName != 'modules') {
$sortedConfig->getNode()->appendChild($node);
}
}
foreach ($moduleDepends as $moduleProp) {
$node = $unsortedConfig->getNode('modules/' . $moduleProp['module']);
$sortedConfig->getNode('modules')->appendChild($node);
}
$this->extend($sortedConfig);
Varien_Profiler::stop('config/load-modules-declaration');
return $this;
}
示例7: isRedisEnabled
protected function isRedisEnabled()
{
$fileConfig = new Mage_Core_Model_Config_Base();
$fileConfig->loadFile(Mage::getBaseDir('etc') . DS . 'modules' . DS . 'Cm_RedisSession.xml');
$isActive = $fileConfig->getNode('modules/Cm_RedisSession/active');
if (!$isActive || !in_array((string) $isActive, array('true', '1'))) {
return false;
}
return true;
}
示例8: isModuleEnabled
public function isModuleEnabled($module)
{
$fileConfig = new Mage_Core_Model_Config_Base();
$fileConfig->loadFile(Mage::getBaseDir('etc') . DS . 'modules' . DS . $module . '.xml');
$isActive = $fileConfig->getNode('modules/' . $module . '/active');
if (!$isActive || !in_array((string) $isActive, array('true', '1'))) {
return false;
}
return true;
}
示例9: loadModulesConfiguration
/**
* Iterate all active modules "etc" folders and combine data from
* specidied xml file name to one object
*
* @param string $fileName
* @param null|Mage_Core_Model_Config_Base $mergeToObject
* @return Mage_Core_Model_Config_Base
*/
public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel = null)
{
$disableLocalModules = !$this->_canUseLocalModules();
if ($mergeToObject === null) {
$mergeToObject = new Mage_Core_Model_Config_Base();
$mergeToObject->loadString('<config/>');
}
if ($mergeModel === null) {
$mergeModel = new Mage_Core_Model_Config_Base();
}
$modules = $this->getNode('modules')->children();
foreach ($modules as $modName => $module) {
if ($module->is('active')) {
if ($disableLocalModules && 'local' === (string) $module->codePool) {
continue;
}
$configFile = $this->getModuleDir('etc', $modName) . DS . $fileName;
if ($mergeModel->loadFile($configFile)) {
$mergeToObject->extend($mergeModel, true);
}
}
}
return $mergeToObject;
}
示例10: _checkRewrites
protected function _checkRewrites()
{
$this->section('Rewrites Information');
$types = array('models' => 'Models', 'blocks' => 'Blocks', 'helpers' => 'Helpers');
$this->output('/!\\ Only active modules are considered and core modules are ignored');
$this->output('The script will also try to find possible conflicts between classes', 4);
$this->br();
$rewrites = array();
$modules = $this->_config->getNode('modules')->children();
foreach ($modules as $moduleName => $module) {
if ($module->is('active') && $module->codePool != 'core') {
$mergeModel = new Mage_Core_Model_Config_Base();
$configFile = $this->_config->getModuleDir('etc', $moduleName) . DS . 'config.xml';
if ($data = $mergeModel->loadFile($configFile)) {
foreach ($types as $type => $label) {
$list = $mergeModel->getNode()->global->{$type};
if ($list) {
foreach ($list->children() as $key => $data) {
if ($data->rewrite) {
foreach ($data->rewrite->children() as $path => $value) {
$rewrites[$type]["{$key}/{$path}"][$moduleName] = (string) $value;
}
}
}
}
}
}
}
}
if (empty($rewrites)) {
$this->output('No class rewrites found');
} else {
foreach ($rewrites as $type => $list) {
$this->output(sprintf('%s (%s)', $this->bold($types[$type]), count($list)));
foreach ($list as $key => $modules) {
if (count($modules) === 1) {
$this->output($this->bold($key), 2);
} else {
$this->error(sprintf('%s (possible classes conflicts)', $this->bold($key)), 2);
}
foreach ($modules as $module => $class) {
$this->start($this->pad($module, 40), 4);
$this->output($class);
}
}
$this->br();
}
}
return $this;
}
示例11: init
/**
* Initialization of core configuration
*
* @return Mage_Core_Model_Config
*/
public function init($etcDir = null)
{
$this->setCacheChecksum(null);
$saveCache = true;
if (is_null($etcDir)) {
$etcDir = Mage::getRoot() . DS . 'etc';
}
$this->_customEtcDir = $etcDir;
$this->loadFile($etcDir . DS . 'local.xml');
// check if local modules are disabled
$disableLocalModules = (string) $this->getNode('global/disable_local_modules');
$disableLocalModules = !empty($disableLocalModules) && ('true' === $disableLocalModules || '1' === $disableLocalModules);
if ($disableLocalModules) {
/**
* Reset include path
*/
set_include_path(BP . '/app/code/community' . PS . BP . '/app/code/core' . PS . BP . '/lib' . PS . Mage::registry('original_include_path'));
}
Varien_Profiler::start('config/load-cache');
if (Mage::app()->isInstalled()) {
if ($this->loadCache()) {
if (!Mage::app()->useCache('config')) {
Mage::app()->removeCache($this->getCacheId());
} else {
Varien_Profiler::stop('config/load-cache');
return $this;
}
}
if (!Mage::app()->useCache('config')) {
$saveCache = false;
}
} else {
$saveCache = false;
}
Varien_Profiler::stop('config/load-cache');
$mergeConfig = new Mage_Core_Model_Config_Base();
/**
* Load base configuration data
*/
Varien_Profiler::start('config/load-base');
$configFile = $etcDir . DS . 'config.xml';
$this->loadFile($configFile);
$moduleFiles = glob($etcDir . DS . 'modules' . DS . '*.xml');
if ($moduleFiles) {
foreach ($moduleFiles as $file) {
$mergeConfig->loadFile($file);
$this->extend($mergeConfig);
}
}
Varien_Profiler::stop('config/load-base');
/**
* Load local configuration data
*/
Varien_Profiler::start('config/load-local');
$configFile = $etcDir . DS . 'local.xml';
if (is_readable($configFile)) {
$mergeConfig->loadFile($configFile);
$this->extend($mergeConfig);
$localConfigLoaded = true;
} else {
$localConfigLoaded = false;
}
Varien_Profiler::stop('config/load-local');
if (!$localConfigLoaded) {
Varien_Profiler::start('config/load-distro');
$mergeConfig->loadString($this->loadDistroConfig());
$this->extend($mergeConfig, true);
Varien_Profiler::stop('config/load-distro');
$saveCache = false;
}
/**
* Load modules configuration data
*/
Varien_Profiler::start('config/load-modules');
$modules = $this->getNode('modules')->children();
foreach ($modules as $modName => $module) {
if ($module->is('active')) {
if ($disableLocalModules && 'local' === (string) $module->codePool) {
continue;
}
$configFile = $this->getModuleDir('etc', $modName) . DS . 'config.xml';
if ($mergeConfig->loadFile($configFile)) {
$this->extend($mergeConfig, true);
}
}
}
Varien_Profiler::stop('config/load-modules');
Varien_Profiler::start('config/apply-extends');
$this->applyExtends();
Varien_Profiler::stop('config/apply-extends');
/**
* Load configuration from DB
*/
if ($localConfigLoaded) {
Varien_Profiler::start('dbUpdates');
//.........这里部分代码省略.........
示例12: _addConfigFile
/**
* Add a config file to the given merge config
*
* @param string $fileName File to load
* @param Mage_Core_Model_Config_Base $mergeConfig Global config for merging
*/
protected function _addConfigFile($fileName, $mergeConfig, $overwrite = true)
{
$config = Mage::getConfig();
$configFile = $config->getModuleDir('etc', 'FireGento_MageSetup') . DS . $this->getCountry() . DS . $fileName;
// If the given file does not exist, use the default file
if (!file_exists($configFile)) {
$configFile = $config->getModuleDir('etc', 'FireGento_MageSetup') . DS . 'default' . DS . $fileName;
}
// Load the given config file
if (file_exists($configFile)) {
if ($mergeConfig->loadFile($configFile)) {
$config->extend($mergeConfig, $overwrite);
}
}
}