Changeset 888 for trunk/Application/Core.php
- Timestamp:
- Dec 27, 2022, 7:50:23 PM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r884 r888 1 1 <?php 2 2 3 class Core extends Application3 class Core extends System 4 4 { 5 var $Config; 6 var $PathItems; 7 var $Menu; 8 var $DoNotShowPage; 9 var $OnPageNotFound; 10 var $Pages; 11 /* @var LocaleManager */ 12 var $LocaleManager; 13 var $Bars; 14 var $PageHeaders; 15 var $BaseURL; 5 public array $Config; 6 public array $PathItems; 7 public array $Menu; 8 public bool $DoNotShowPage; 9 public array $OnPageNotFound; 10 public LocaleManager $LocaleManager; 11 public array $Bars; 12 public array $PageHeaders; 13 public string $BaseURL; 16 14 17 15 function __construct() … … 103 101 } 104 102 105 function Run() 103 static function Cast(System $System): Core 104 { 105 if ($System instanceof Core) 106 { 107 return $System; 108 } 109 throw new Exception('Expected Core type but '.gettype($System)); 110 } 111 112 function Run(): void 106 113 { 107 114 global $ScriptStartTime, $StopAfterUpdateManager, … … 126 133 $this->Init(); 127 134 128 // Register and start existing modules 129 $this->Setup = new Setup($this); 130 $this->Setup->Start(); 131 $this->Setup->UpdateManager->VersionTable = 'DbVersion'; 132 if ($this->Setup->CheckState()) 133 { 134 $this->ModuleManager->Start(); 135 } 135 $this->StartModules(); 136 136 137 137 $this->BaseView = new BaseView($this); … … 142 142 } 143 143 144 function StartModules(): void 145 { 146 $ModuleSetup = $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/Setup.php'); 147 ModuleSetup::Cast($ModuleSetup)->UpdateManager->VersionTable = 'DbVersion'; 148 $ModuleSetup->Install(); 149 $ModuleSetup->Start(); 150 $this->ModuleManager->LoadModules(); 151 $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/ModuleManager.php'); 152 if (file_exists($this->ModuleManager->FileName)) $this->ModuleManager->LoadState(); 153 if (ModuleSetup::Cast($ModuleSetup)->CheckState()) 154 { 155 $this->ModuleManager->StartAll(array(ModuleCondition::Enabled)); 156 } 157 } 158 144 159 function GetMicrotime() 145 160 { … … 148 163 } 149 164 150 function Link( $Target)165 function Link(string $Target): string 151 166 { 152 167 if (substr($Target, 0, strlen($this->BaseURL)) == $this->BaseURL) … … 235 250 return $this->BaseURL.$Target; 236 251 return $this->BaseURL.'/'.$Locale.$Target; 237 }238 239 function RegisterPage($Path, $Handler)240 {241 if (is_array($Path))242 {243 $Page = &$this->Pages;244 $LastKey = array_pop($Path);245 foreach ($Path as $PathItem)246 {247 $Page = &$Page[$PathItem];248 }249 if (!is_array($Page)) $Page = array('' => $Page);250 $Page[$LastKey] = $Handler;251 } else $this->Pages[$Path] = $Handler;252 252 } 253 253
Note:
See TracChangeset
for help on using the changeset viewer.