Changeset 898 for trunk/Packages/Common/AppModule.php
- Timestamp:
- Feb 4, 2021, 11:55:44 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/AppModule.php
r897 r898 71 71 $this->Version = ''; 72 72 $this->Creator = ''; 73 $this->Title = ''; 73 74 $this->Description = ''; 74 75 $this->Dependencies = array(); … … 85 86 { 86 87 if ($this->Installed) return; 88 echo('Install mod '.$this->Name.'<br/>'); 87 89 $List = array(); 88 90 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled)); 89 91 $this->Manager->PerformList($List, array(ModuleAction::Install), array(ModuleCondition::NotInstalled)); 90 $this->DoBeforeInstall();91 $this->InstallModels();92 $this->DoInstall();93 92 $this->Installed = true; 94 93 $this->Enabled = true; // Automatically enable installed module 95 94 $this->InstalledVersion = $this->Version; 96 95 $this->Manager->Modules[$this->Name] = $this; 96 $this->DoBeforeInstall(); 97 if ($this->Manager->OnInstallModule != null) 98 { 99 call_user_func($this->Manager->OnInstallModule, $this); 100 } 101 $this->InstallModels(); 102 $this->DoInstall(); 97 103 } 98 104 … … 107 113 $this->DoUninstall(); 108 114 $this->UninstallModels(); 115 if ($this->Manager->OnUninstallModule != null) 116 { 117 call_user_func($this->Manager->OnUninstallModule, $this); 118 } 109 119 $this->DoAfterUninstall(); 110 120 } … … 214 224 foreach ($this->GetModels() as $Model) 215 225 { 216 call_user_func($this->Manager->OnInstallModel, $Model::GetDesc() );226 call_user_func($this->Manager->OnInstallModel, $Model::GetDesc(), $this); 217 227 } 218 228 } … … 225 235 foreach (array_reverse($this->GetModels()) as $Model) 226 236 { 227 call_user_func($this->Manager->OnUninstallModel, $Model::GetDesc() );237 call_user_func($this->Manager->OnUninstallModel, $Model::GetDesc(), $this); 228 238 } 229 239 } … … 241 251 public $OnInstallModel; 242 252 public $OnUninstsallModel; 253 public $OnInstallModule; 254 public $OnUninstsallModule; 243 255 244 256 function __construct(System $System) … … 250 262 $this->OnInstallModel = null; 251 263 $this->OnUninstallModel = null; 264 $this->OnInstallModule = null; 265 $this->OnUninstallModule = null; 252 266 } 253 267 … … 456 470 } 457 471 472 function GetUniqueModuleId() 473 { 474 $Id = 1; 475 foreach ($this->Modules as $Module) 476 { 477 if ($Module->Id >= $Id) $Id = $Module->Id + 1; 478 } 479 return $Id; 480 } 481 458 482 function LoadModule(string $FileName): AppModule 459 483 { … … 461 485 $ModuleName = 'Module'.pathinfo($FileName, PATHINFO_FILENAME); 462 486 $Module = new $ModuleName($this->System); 487 $Module->Id = $this->GetUniqueModuleId(); 463 488 $this->RegisterModule($Module); 464 489 return $Module;
Note:
See TracChangeset
for help on using the changeset viewer.