Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/EmailQueue/EmailQueue.php

    r882 r887  
    33class PageEmailQueueProcess extends Page
    44{
    5   var $FullTitle = 'Odeslání pošty z fronty';
    6   var $ShortTitle = 'Fronta pošty';
    7   var $ParentClass = 'PagePortal';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Odeslání pošty z fronty';
     9    $this->ShortTitle = 'Fronta pošty';
     10    $this->ParentClass = 'PagePortal';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();
     15    $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process();
    1216    $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output;
    1317    return $Output;
     
    1721class ModuleEmailQueue extends AppModule
    1822{
    19   function __construct($System)
     23  function __construct(System $System)
    2024  {
    2125    parent::__construct($System);
     
    2832  }
    2933
    30   function DoInstall()
     34  function DoInstall(): void
    3135  {
    3236  }
    3337
    34   function DoUninstall()
     38  function DoUninstall(): void
    3539  {
    3640  }
    3741
    38   function DoStart()
     42  function DoStart(): void
    3943  {
    40     $this->System->RegisterPage('fronta-posty', 'PageEmailQueueProcess');
     44    $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess');
    4145    $this->System->FormManager->RegisterClass('Email', array(
    4246        'Title' => 'Nový email',
     
    7074  }
    7175
    72   function DoStop()
     76  function DoStop(): void
    7377  {
    7478  }
     
    8387  }
    8488
    85   function Process()
     89  function Process(): string
    8690  {
    8791    $Output = '';
     
    103107      $Mail->Send();
    104108      $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1));
    105       $this->System->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);
     109      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('System', 'SendEmail', $DbRow['Id']);
    106110      $Output .= 'To: '.$DbRow['To'].'  Subject: '.$DbRow['Subject'].'<br />';
    107111    }
    108112    return $Output;
    109113  }
     114
     115  static function Cast(AppModule $AppModule): ModuleEmailQueue
     116  {
     117    if ($AppModule instanceof ModuleEmailQueue)
     118    {
     119      return $AppModule;
     120    }
     121    throw new Exception('Expected ModuleEmailQueue type but '.gettype($AppModule));
     122  }
    110123}
    111 
Note: See TracChangeset for help on using the changeset viewer.