コード例 #1
0
 public function prepare()
 {
     $this->_merge = new Aitoc_Aitsys_Model_Rewriter_Merge();
     $this->_rewriterConfig = new Aitoc_Aitsys_Model_Rewriter_Config();
     // first clearing current class rewrites
     Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->clearConfig();
     $this->_merge->clear();
     $rewriteHelper = Mage::helper('aitsys/rewriter');
     $result = array();
     if ($rewriteHelper->analysisInheritedClasses($this, 'mergeFilesFromClass', $result)) {
         $this->_rewriterConfig->commit();
     }
     Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->setupConfig();
 }
コード例 #2
0
ファイル: Rewriter.php プロジェクト: CherylMuniz/fashion
 public function prepare()
 {
     $merge = new Aitoc_Aitsys_Model_Rewriter_Merge();
     $rewriterConfig = new Aitoc_Aitsys_Model_Rewriter_Config();
     // first clearing current class rewrites
     Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->clearConfig();
     $merge->clear();
     $conflict = new Aitoc_Aitsys_Model_Rewriter_Conflict();
     list($conflicts, $rewritesAbstract) = $conflict->getConflictList();
     /**
      * FOR NORMAL REWRITES
      */
     // will combine rewrites by alias groups
     if (!empty($conflicts)) {
         foreach ($conflicts as $groupType => $modules) {
             $groupType = substr($groupType, 0, -1);
             foreach ($modules as $moduleName => $moduleRewrites) {
                 foreach ($moduleRewrites['rewrite'] as $moduleClass => $rewriteClasses) {
                     /*
                      * $rewriteClasses is an array of class names for one rewrite alias
                      * for example:
                      * Array
                      *   (
                      *       [0] => AdjustWare_Deliverydate_Model_Rewrite_AdminhtmlSalesOrderCreate
                      *       [4] => Aitoc_Aitcheckoutfields_Model_Rewrite_AdminSalesOrderCreate
                      *       [10] => Aitoc_Aitorderedit_Model_Rewrite_AdminSalesOrderCreate
                      *   )
                      */
                     // building inheritance tree
                     $alias = $moduleName . '/' . $moduleClass;
                     $classModel = new Aitoc_Aitsys_Model_Rewriter_Class();
                     $inheritanceModel = new Aitoc_Aitsys_Model_Rewriter_Inheritance();
                     $baseClass = $classModel->getBaseClass($groupType, $alias);
                     $inheritedClasses = $inheritanceModel->build($rewriteClasses, $baseClass);
                     // don't create rewrites for excluded Magento base classes
                     if (in_array($baseClass, $this->tool()->db()->getConfigValue('aitsys_rewriter_exclude_classes', array()))) {
                         continue;
                     }
                     $mergedFilename = $merge->merge($inheritedClasses);
                     if ($mergedFilename) {
                         $rewriterConfig->add($mergedFilename, $rewriteClasses);
                         $rewriterConfig->add(serialize($merge->getLatestMergedFiles()), 'file:' . $mergedFilename);
                     }
                 }
             }
         }
     }
     /**
      * FOR ABSTRACT REWRITES (AITOC REALIZATION)
      */
     if (!empty($rewritesAbstract)) {
         foreach ($rewritesAbstract as $groupType => $modules) {
             $groupType = substr($groupType, 0, -1);
             foreach ($modules as $moduleName => $moduleRewrites) {
                 foreach ($moduleRewrites['rewriteabstract'] as $moduleClass => $rewriteClass) {
                     // building inheritance tree
                     $alias = $moduleName . '/' . $moduleClass;
                     $classModel = new Aitoc_Aitsys_Model_Rewriter_Class();
                     $inheritanceModel = new Aitoc_Aitsys_Model_Rewriter_Inheritance();
                     $baseClass = $classModel->getBaseClass($groupType, $alias);
                     $inheritedClasses = $inheritanceModel->buildAbstract($rewriteClass, $baseClass);
                     $mergedFilename = $merge->merge($inheritedClasses);
                     if ($mergedFilename) {
                         $rewriterConfig->add($mergedFilename, array($rewriteClass, $baseClass));
                     }
                 }
             }
         }
     }
     $rewriterConfig->commit();
     Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->setupConfig();
 }