当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:52,代码来源:Config.php

示例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;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:60,代码来源:Tool.php


注:本文中的Mage_Core_Model_Config_Base::getXpath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。