Changeset 900 for trunk/Packages/Common


Ignore:
Timestamp:
Feb 17, 2021, 5:15:29 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Insert sample data action partially implemented.
Location:
trunk/Packages/Common
Files:
5 edited

Legend:

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

    r898 r900  
    134134  }
    135135
    136   function insert(string $Table, array $Data): void
     136  function insert(string $Table, array $Data): int
    137137  {
    138138    $this->query($this->GetInsert($Table, $Data));
    139139    $this->insert_id = $this->PDO->lastInsertId();
     140    return $this->insert_id;
    140141  }
    141142
  • trunk/Packages/Common/Module.php

    r899 r900  
    1717  const Enable = 5;
    1818  const Disable = 6;
     19  const InsertSampleData = 7;
    1920}
    2021
     
    141142  }
    142143
     144  function InsertSampleData(): void
     145  {
     146    $this->DoInsertSampleData();
     147  }
     148
    143149  function Reinstall(): void
    144150  {
     
    224230  }
    225231
     232  protected function DoInsertSampleData(): void
     233  {
     234  }
     235
    226236  function AddModel(Model $Model): void
    227237  {
  • trunk/Packages/Common/ModuleManager.php

    r899 r900  
    5757          if ($Action == ModuleAction::Disable) $Module->Disable();
    5858          if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
     59          if ($Action == ModuleAction::InsertSampleData) $Module->InsertSampleData();
    5960        }
    6061      }
     
    227228  function RegisterModule(Module $Module): void
    228229  {
     230    if (array_key_exists($Module->Name, $this->Modules))
     231      die('Can\'t register module '.$Module->Name.' because it already exists.');
    229232    $this->Modules[$Module->Name] = &$Module;
    230233    $Module->Manager = &$this;
  • trunk/Packages/Common/Modules/ModuleManager.php

    r899 r900  
    260260      $ModelId = $DbRow['Id'];
    261261      $DbResult = $this->Database->delete('ModelField', '(Model='.$ModelId.')');
    262     }
    263     $this->Database->delete('Model', '(Id='.$ModelId.')');
     262      $this->Database->delete('Model', '(Id='.$ModelId.')');
     263    } else echo('Can\'t remove model '.$ModelDesc->Name.'<br/>');
    264264    $this->RemoveModelDatabase($ModelDesc);
    265265  }
  • trunk/Packages/Common/Modules/Setup.php

    r899 r900  
    5959    $Output = $this->UpdateManager->Upgrade();
    6060    return $Output;
    61   }
    62 
    63   function InsertSampleData(): void
    64   {
    6561  }
    6662}
     
    8177    $this->FullTitle = T('Application setup');
    8278    $this->ShortTitle = T('Application setup');
    83     //$this->ParentClass = 'PagePortal';
     79    //$this->ParentClass = 'PageSetupRedirect';
    8480    $this->ConfigDir = dirname(dirname(dirname(__FILE__))).'/Config';
    8581    $this->YesNo = array(false => T('No'), true => T('Yes'));
     
    212208        {
    213209          $Output .= '<h3>Vložení vzorových dat</h3>';
    214           ModuleSetup::Cast($this->System->GetModule('Setup'))->InsertSampleData();
     210          $this->System->ModuleManager->Perform(array(ModuleAction::InsertSampleData), array(ModuleCondition::Installed));
    215211          $Output .= $this->ControlPanel();
    216212        }
Note: See TracChangeset for help on using the changeset viewer.