Skip to content

Commit

Permalink
Chanaged the way the Model class gets loaded. This means that it is n…
Browse files Browse the repository at this point in the history
…ow possible to run Trongate web applications entirely without a database of any kind
  • Loading branch information
trongate committed Feb 11, 2023
1 parent eea100c commit 72cbf0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 8 additions & 2 deletions engine/Dynamic_properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ trait Dynamic_properties {
public function __set(string $key, object $value): void {
$this->attributes[$key] = $value;
}

public function __get(string $key) {

if (!isset($this->attributes[$key])) {
if ($key === 'model') {
if (!isset($this->model)) {
require_once 'Model.php';
$this->model = new Model($this->module_name);
}
return $this->model;
} elseif (!isset($this->attributes[$key])) {
$class_name = ucfirst($key);
$this->$key = new $key;
}
Expand Down
6 changes: 1 addition & 5 deletions engine/Trongate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class Trongate {

use Dynamic_properties;

private $model;
protected $modules;
protected $model;
protected $url;
protected $module_name;
protected $parent_module = '';
Expand All @@ -13,10 +13,6 @@ class Trongate {
public function __construct($module_name=NULL) {
$this->module_name = $module_name;
$this->modules = new Modules;

//load the model class
require_once 'Model.php';
$this->model = new Model($module_name);
}

public function load($helper) {
Expand Down

0 comments on commit 72cbf0c

Please sign in to comment.