本文整理汇总了PHP中Mage_Core_Model_Config_Base::getXpath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Config_Base::getXpath方法的具体用法?PHP Mage_Core_Model_Config_Base::getXpath怎么用?PHP Mage_Core_Model_Config_Base::getXpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Config_Base
的用法示例。
在下文中一共展示了Mage_Core_Model_Config_Base::getXpath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: _generateClassRewriteConflictsData
/**
* Generate class rewrite conflicts
*
* @return array
*/
protected function _generateClassRewriteConflictsData()
{
$modules = Mage::app()->getConfig()->getNode('modules')->children();
$data = $systemReport = $_conflicts = $_rewrites = array();
foreach ($modules as $modName => $module) {
$configFile = $this->_getModulePath($modName, $this->_getModuleCodePoolByClassName($modName));
$configFile .= 'etc' . DS . 'config.xml';
try {
$config = new Mage_Core_Model_Config_Base($configFile);
} catch (Exception $e) {
//
}
if (!isset($config)) {
continue;
}
$classes = $config->getXpath('global/*/*/rewrite');
if (!$classes) {
continue;
}
/** @var $element Mage_Core_Model_Config_Element */
foreach ($classes as $element) {
//module node
$moduleNode = $element->getParent();
//scope node (models|blocks|helpers)
$scopeNode = $moduleNode->getParent();
//scope name
$scopeName = $scopeNode->getName();
if (!in_array($scopeName, array('models', 'blocks', 'helpers'))) {
continue;
}
/** @var $rewrite Mage_Core_Model_Config_Element */
foreach ($element as $rewrite) {
$_rewriteFactoryName = $element->getParent()->getName() . '/' . $rewrite->getName();
if (!array_key_exists($_rewriteFactoryName, $_rewrites)) {
$_rewrites[$_rewriteFactoryName] = array('pool' => (string) $module->codePool, 'rewrite' => trim($rewrite), 'is_active' => $this->_isModuleActiveByClassName($modName));
} else {
if (!array_key_exists($_rewriteFactoryName, $_conflicts)) {
$_conflicts[$_rewriteFactoryName][] = $_rewrites[$_rewriteFactoryName];
}
$_conflicts[$_rewriteFactoryName][] = array('pool' => (string) $module->codePool, 'rewrite' => trim($rewrite), 'is_active' => $this->_isModuleActiveByClassName($modName));
}
}
}
unset($config);
}
if ($_conflicts) {
foreach ($_conflicts as $factoryName => $conflicts) {
foreach ($conflicts as $conflict) {
$data[] = array($factoryName, $conflict['rewrite'] . "\n" . ' {' . $this->_getClassPath($conflict['rewrite'], $conflict['pool']) . '}', $conflict['is_active'] ? 'Yes' : 'No');
}
}
}
$systemReport['Class Rewrite Conflicts'] = array('header' => array('Factory Name', 'Class', 'Is Active'), 'data' => $data);
return $systemReport;
}