Started working on Model Type loading based on Events

This commit is contained in:
Abel Hoogeveen 2015-02-26 14:09:08 +01:00
parent 8a320bbe3e
commit e3ab0da0cc
3 changed files with 32 additions and 3 deletions

View File

@ -1,6 +1,14 @@
<?php
class Model {
public function onLoad(){}
class DatabaseModelManager extends Module {
public function onLoad(){
$this->events->addListener(array($this, 'eventRegisterBuild'), 'eventRegisterBuildEvent', EventPriority::NORMAL);
}
public function eventRegisterBuild($event) {
$event->addEvent('databasemodel', 'loadModelsEvent');
return $event;
}
}
class DatabaseModel extends Bus{

View File

@ -0,0 +1,16 @@
<?php
return array(
'module_class' => 'DatabaseModelManager',
'module_file' => 'class.model.php',
'module_name' => 'databasemodel',
'name' => 'DatabaseModel',
'description' => 'Abstract type for easy database queries',
'author' => 'TechFuze',
'version' => '1.0.0',
'website' => 'http://fuzeworks.techfuze.net/',
'date_created' => '26-02-2015',
'date_updated' => '26-02-2015',
);

View File

@ -7,13 +7,18 @@ class Models extends Bus{
private $models_array = array();
private $model_types = array();
private $models_loaded = false;
public function __construct(&$core){
parent::__construct($core);
}
public function loadModel($name, $directory = null){
$this->core->loadMod('model');
if ($this->models_loaded) {
$this->events->fireEvent('modelsLoadEvent');
$this->models_loaded = true;
}
if($directory === null){
$directory = FUZEPATH . "/Application/Models";
}