Ticket #132: engine_patch.patch

File engine_patch.patch, 1.7 KB (added by ort, 22 months ago)
  • classes/Engine.class.php

     
    121121                                $oProfiler=ProfilerSimple::getInstance(); 
    122122                                $iTimeId=$oProfiler->Start('InitModule',get_class($oModule)); 
    123123 
    124                                 $oModule->Init(); 
    125                                 $oModule->SetInit(); 
     124                                $this->InitModule($oModule); 
    126125 
    127126                                $oProfiler->Stop($iTimeId); 
    128127                        } 
    129128                } 
    130129        } 
    131130         
     131        protected function InitModule($oModule){ 
     132                $sOrigClassName = $sClassName = get_class($oModule);             
     133                $bRunHooks = false; 
     134                 
     135                $aModuleHook = $this->GetModule('Hook_x');               
     136                if($aModuleHook[0]->isInit()){ 
     137                        $bRunHooks = true; 
     138                        while(preg_match('#^Plugin#i', $sClassName)){ 
     139                                $sParentClassName = get_parent_class($sClassName); 
     140                                if($sParentClassName == 'Module'){ 
     141                                        break; 
     142                                } 
     143                                $sClassName = $sParentClassName; 
     144                        } 
     145                } 
     146                 
     147                if($bRunHooks){ 
     148                        $this->Hook_Run('module_init_'.$sClassName.'_before'); 
     149                } 
     150                $oModule->Init(); 
     151                $oModule->SetInit(); 
     152                if($bRunHooks || $sClassName == 'ModuleHook'){ 
     153                        $this->Hook_Run('module_init_'.$sClassName.'_after'); 
     154                } 
     155        } 
     156         
    132157        /** 
    133158         * Завершаем работу всех модулей 
    134159         * 
     
    160185                 * Создаем объект модуля 
    161186                 */              
    162187                $oModule=new $sModuleName($this); 
    163                 if ($bInit or $sModuleName=='Cache') { 
    164                         $oModule->Init(); 
    165                         $oModule->SetInit(); 
    166                 } 
    167188                $this->aModules[$sModuleName]=$oModule; 
     189                if ($bInit or $sModuleName=='ModuleCache') { 
     190                        $this->InitModule($oModule); 
     191                }                
    168192                $tm2=microtime(true); 
    169193                $this->iTimeLoadModule+=$tm2-$tm1; 
    170194                dump("load $sModuleName - \t\t".($tm2-$tm1)."");