Ignore:
Timestamp:
Jun 1, 2023, 12:18:18 AM (19 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Modified: Form types made as separate FormManager package.
  • Fixed: PHP 8.1 support.
File:
1 edited

Legend:

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

    r7 r8  
    33class UpdateManager
    44{
    5   var $Revision;
    6   var $Trace;
    7   var $VersionTable;
    8   /* @var Database */
    9   var $Database;
    10   var $InstallMethod;
     5  public int $Revision;
     6  public array $Trace;
     7  public string $VersionTable;
     8  public Database $Database;
     9  public string $InstallMethod;
     10  public $InsertSampleDataMethod;
    1111
    1212  function __construct()
     
    1919  }
    2020
    21   function GetDbVersion()
     21  function GetDbVersion(): ?int
    2222  {
    2323    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
     
    2626  }
    2727
    28   function IsInstalled()
     28  function IsInstalled(): bool
    2929  {
    3030    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
     
    3232  }
    3333
    34   function IsUpToDate()
     34  function IsUpToDate(): bool
    3535  {
    3636    return $this->Revision <= $this->GetDbVersion();
    3737  }
    3838
    39   function Upgrade()
     39  function Upgrade(): string
    4040  {
    4141    $DbRevision = $this->GetDbVersion();
     
    4343    while ($this->Revision > $DbRevision)
    4444    {
     45      if (!array_key_exists($DbRevision, $this->Trace))
     46        die('Missing upgrade trace for revision '.$DbRevision);
    4547      $TraceItem = $this->Trace[$DbRevision];
    4648      $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
     
    5759  }
    5860
    59   function Install()
     61  function Install(): void
    6062  {
    6163    $InstallMethod = $this->InstallMethod;
    6264    $InstallMethod($this);
    63     $this->Update();
    6465  }
    6566
    66   function Uninstall()
     67  function Uninstall(): void
    6768  {
    68 
    6969  }
    7070
    71   function InsertSampleData()
     71  function InsertSampleData(): void
    7272  {
    7373    $InstallMethod = $this->InsertSampleDataMethod;
     
    7575  }
    7676
    77   function Execute($Query)
     77  function Execute(string $Query): DatabaseResult
    7878  {
    7979    echo($Query.';<br/>');
Note: See TracChangeset for help on using the changeset viewer.