Ignore:
Timestamp:
Feb 4, 2021, 11:55:44 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Initialization of modular system base tables.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/AppModule.php

    r897 r898  
    7171    $this->Version = '';
    7272    $this->Creator = '';
     73    $this->Title = '';
    7374    $this->Description = '';
    7475    $this->Dependencies = array();
     
    8586  {
    8687    if ($this->Installed) return;
     88    echo('Install mod '.$this->Name.'<br/>');
    8789    $List = array();
    8890    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled));
    8991    $this->Manager->PerformList($List, array(ModuleAction::Install), array(ModuleCondition::NotInstalled));
    90     $this->DoBeforeInstall();
    91     $this->InstallModels();
    92     $this->DoInstall();
    9392    $this->Installed = true;
    9493    $this->Enabled = true; // Automatically enable installed module
    9594    $this->InstalledVersion = $this->Version;
    9695    $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();
    97103  }
    98104
     
    107113    $this->DoUninstall();
    108114    $this->UninstallModels();
     115    if ($this->Manager->OnUninstallModule != null)
     116    {
     117      call_user_func($this->Manager->OnUninstallModule, $this);
     118    }
    109119    $this->DoAfterUninstall();
    110120  }
     
    214224      foreach ($this->GetModels() as $Model)
    215225      {
    216         call_user_func($this->Manager->OnInstallModel, $Model::GetDesc());
     226        call_user_func($this->Manager->OnInstallModel, $Model::GetDesc(), $this);
    217227      }
    218228    }
     
    225235      foreach (array_reverse($this->GetModels()) as $Model)
    226236      {
    227         call_user_func($this->Manager->OnUninstallModel, $Model::GetDesc());
     237        call_user_func($this->Manager->OnUninstallModel, $Model::GetDesc(), $this);
    228238      }
    229239    }
     
    241251  public $OnInstallModel;
    242252  public $OnUninstsallModel;
     253  public $OnInstallModule;
     254  public $OnUninstsallModule;
    243255
    244256  function __construct(System $System)
     
    250262    $this->OnInstallModel = null;
    251263    $this->OnUninstallModel = null;
     264    $this->OnInstallModule = null;
     265    $this->OnUninstallModule = null;
    252266  }
    253267
     
    456470  }
    457471
     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
    458482  function LoadModule(string $FileName): AppModule
    459483  {
     
    461485    $ModuleName = 'Module'.pathinfo($FileName, PATHINFO_FILENAME);
    462486    $Module = new $ModuleName($this->System);
     487    $Module->Id = $this->GetUniqueModuleId();
    463488    $this->RegisterModule($Module);
    464489    return $Module;
Note: See TracChangeset for help on using the changeset viewer.