Ignore:
Timestamp:
Dec 27, 2022, 7:50:23 PM (17 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package to latest version.
  • Modified: Fixes related to PHP 8.x.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r884 r888  
    11<?php
    22
    3 class Core extends Application
     3class Core extends System
    44{
    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;
    1614
    1715  function __construct()
     
    103101  }
    104102
    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
    106113  {
    107114    global $ScriptStartTime, $StopAfterUpdateManager,
     
    126133    $this->Init();
    127134
    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();
    136136
    137137    $this->BaseView = new BaseView($this);
     
    142142  }
    143143
     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
    144159  function GetMicrotime()
    145160  {
     
    148163  }
    149164
    150   function Link($Target)
     165  function Link(string $Target): string
    151166  {
    152167    if (substr($Target, 0, strlen($this->BaseURL)) == $this->BaseURL)
     
    235250      return $this->BaseURL.$Target;
    236251    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;
    252252  }
    253253
Note: See TracChangeset for help on using the changeset viewer.