本文整理汇总了PHP中Mage_Core_Model_Config_Base::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Config_Base::extend方法的具体用法?PHP Mage_Core_Model_Config_Base::extend怎么用?PHP Mage_Core_Model_Config_Base::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Config_Base
的用法示例。
在下文中一共展示了Mage_Core_Model_Config_Base::extend方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPackageConfiguration
/**
* 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 loadPackageConfiguration($mergeToObject = null, $mergeModel = null)
{
if ($mergeToObject === null) {
$mergeToObject = new Mage_Core_Model_Config_Base();
$mergeToObject->loadString('<config/>');
}
if ($mergeModel === null) {
$mergeModel = new Mage_Core_Model_Config_Base();
}
$channels = Mage::getModel('channel/channel')->getCollection();
foreach ($channels as $id => $channel) {
// if the store is an activated channel
if ($channel->load($id)->isChannel()) {
if ($mergeModel->loadString($channel->getApiConfig())) {
$mergeToObject->extend($mergeModel, true);
}
}
}
/* $packages = Mage::getModel('catalog/product')
->getCollection()
->addFieldToFilter(
'type_id',
Faett_Package_Model_Product_Type::TYPE_PACKAGE
);
foreach ($packages as $id => $package) {
if ($mergeModel->loadString($package->load($id)->getApiConfig())) {
$mergeToObject->extend($mergeModel, true);
}
} */
return $mergeToObject;
}
示例2: _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;
}
示例3: _loadDeclaredModules
/**
* Load declared modules configuration
*
* @return Mage_Core_Model_Config
*/
protected function _loadDeclaredModules()
{
Magento_Profiler::start('load_modules_files');
$moduleFiles = $this->_getDeclaredModuleFiles();
if (!$moduleFiles) {
return $this;
}
Magento_Profiler::stop('load_modules_files');
Magento_Profiler::start('load_modules_declaration');
$unsortedConfig = new Mage_Core_Model_Config_Base('<config/>');
$emptyConfig = new Mage_Core_Model_Config_Element('<config><modules/></config>');
$declaredModules = array();
foreach ($moduleFiles as $oneConfigFile) {
$path = explode(DIRECTORY_SEPARATOR, $oneConfigFile);
$moduleConfig = new Mage_Core_Model_Config_Base($oneConfigFile);
$modules = $moduleConfig->getXpath('modules/*');
if (!$modules) {
continue;
}
$cPath = count($path);
if ($cPath > 4) {
$moduleName = $path[$cPath - 4] . '_' . $path[$cPath - 3];
$this->_modulesCache[$moduleName] = $moduleConfig;
}
foreach ($modules as $module) {
$moduleName = $module->getName();
$isActive = (string) $module->active;
if (isset($declaredModules[$moduleName])) {
$declaredModules[$moduleName]['active'] = $isActive;
continue;
}
$newModule = clone $emptyConfig;
$newModule->modules->appendChild($module);
$declaredModules[$moduleName] = array('active' => $isActive, 'module' => $newModule);
}
}
foreach ($declaredModules as $moduleName => $module) {
if ($module['active'] == 'true') {
$module['module']->modules->{$moduleName}->active = 'true';
$unsortedConfig->extend(new Mage_Core_Model_Config_Base($module['module']));
}
}
$sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules);
$this->extend($sortedConfig);
Magento_Profiler::stop('load_modules_declaration');
return $this;
}
示例4: 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;
}
示例5: mergexmlAction
public function mergexmlAction()
{
/*@davidselo: Action para entender como funciona el merge de los archivos XML*/
/*$first = new Mage_Core_Model_Config_Base;
$first->loadString('<config>
<one></one>
<two></two>
<three></three>
</config>');
$second = new Mage_Core_Model_Config_Base;
$second->loadString('<config>
<four></four>
<five></five>
</config>');
$first->extend($second);
echo $first->getNode()->asNiceXml();*/
/*SALIDA POR PANTALLA:
* <config>
* <one/>
* <two/>
* <three/>
* <four/>
* <five/>
* </config>
*
* */
/*
$first = new Mage_Core_Model_Config_Base;
$first->loadString('<config>
<one></one>
<two></two>
<three></three>
</config>');
$second = new Mage_Core_Model_Config_Base;
$second->loadString('<config>
<one>Hello</one>
<two>Goodby</two>
</config>');
$first->extend($second);
echo $first->getNode()->asNiceXml();*/
/*SALIDA POR PANTALLA:
* <config>
* <three/>
* <one>Hello</one>
* <two>Goodby</two>
* </config>*/
/*$first = new Mage_Core_Model_Config_Base;
$first->loadString('<config>
<one>
<two>
<three></three>
</two>
</one>
</config>');
$second = new Mage_Core_Model_Config_Base;
$second->loadString('<config>
<one>
<two>
<four></four>
</two>
</one>
</config>');
$first->extend($second);
echo $first->getNode()->asNiceXml();
*/
$first = new Mage_Core_Model_Config_Base();
$first->loadString('<config>
<one>
<two>
<three>Original Value</three>
</two>
</one>
</config>');
$second = new Mage_Core_Model_Config_Base();
$second->loadString('<config>
<one>
<two>
<four></four>
<three>New Value</three>
</two>
</one>
</config>');
$first->extend($second, false);
echo $first->getNode()->asNiceXml();
}
示例6: loadPackageConfiguration
/**
* 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 loadPackageConfiguration($mergeToObject = null, $mergeModel = null)
{
// initialize the configuration XML structure to append
if ($mergeToObject === null) {
$mergeToObject = new Mage_Core_Model_Config_Base();
$mergeToObject->loadString('<config/>');
}
// initialize the configuration XML structure
if ($mergeModel === null) {
$mergeModel = new Mage_Core_Model_Config_Base();
}
// load the Collection with all channels
$channels = Mage::getModel('channel/channel')->getCollection();
// iterate over the channels
foreach ($channels as $id => $channel) {
// if the store is an activated channel
if ($channel->load($id)->isChannel()) {
// merge the channel to the ACL's
if ($mergeModel->loadString($channel->getApiConfig())) {
$mergeToObject->extend($mergeModel, true);
}
// load the package Collection
$packages = Mage::helper('channel')->getPackageCollection($channel);
// merge the packages to the channel's ACL's
foreach ($packages as $id => $package) {
if ($mergeModel->loadString($package->load($id)->getApiConfig($channel))) {
$mergeToObject->extend($mergeModel, true);
}
}
}
}
// return the configuration structure
return $mergeToObject;
}