This commit is contained in:
parent
54c81f769a
commit
156f4a3460
20
Core/Events/event.controllerLoadEvent.php
Normal file
20
Core/Events/event.controllerLoadEvent.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ControllerLoadEvent extends Event {
|
||||||
|
|
||||||
|
public $route;
|
||||||
|
public $controllerName;
|
||||||
|
public $function;
|
||||||
|
public $parameters;
|
||||||
|
public $directory;
|
||||||
|
|
||||||
|
public function init($route, $controllerName, $function, $parameters, $directory) {
|
||||||
|
$this->route = $route;
|
||||||
|
$this->controllerName = $controllerName;
|
||||||
|
$this->function = $function;
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
$this->directory = $directory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
13
Core/Events/event.modelLoadEvent.php
Normal file
13
Core/Events/event.modelLoadEvent.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ModelLoadEvent extends Event {
|
||||||
|
|
||||||
|
public $directory;
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public function init($model){
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -14,9 +14,10 @@ class Models extends Bus{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function loadModel($name, $directory = null){
|
public function loadModel($name, $directory = null){
|
||||||
if($directory === null){
|
// Model load event
|
||||||
$directory = FUZEPATH . "/Application/Models";
|
$event = $this->events->fireEvent('modelLoadEvent', $name);
|
||||||
}
|
$directory = ($event->directory === null ? FUZEPATH . "/Application/Models" : $event->directory);
|
||||||
|
$name = ($event->model === null ? $name : $event->model);
|
||||||
|
|
||||||
$file = $directory.'/model.'.$name.'.php';
|
$file = $directory.'/model.'.$name.'.php';
|
||||||
if (isset($this->model_types[$name])) {
|
if (isset($this->model_types[$name])) {
|
||||||
|
@ -5,9 +5,10 @@ class Router extends Bus {
|
|||||||
public $controller = null;
|
public $controller = null;
|
||||||
public $controllerName = null;
|
public $controllerName = null;
|
||||||
public $function = null;
|
public $function = null;
|
||||||
private $route = array();
|
public $route = array();
|
||||||
private $parameters = array();
|
public $parameters = array();
|
||||||
private $path;
|
public $directory;
|
||||||
|
public $path;
|
||||||
|
|
||||||
public function __construct(&$core) {
|
public function __construct(&$core) {
|
||||||
parent::__construct($core);
|
parent::__construct($core);
|
||||||
@ -90,9 +91,6 @@ class Router extends Bus {
|
|||||||
$this->function = ($event->function === null || empty($event->function) ? $this->config->main->default_function : $event->function);
|
$this->function = ($event->function === null || empty($event->function) ? $this->config->main->default_function : $event->function);
|
||||||
$this->parameters = $event->parameters;
|
$this->parameters = $event->parameters;
|
||||||
$this->directory = ($event->directory === null || empty($event->directory) ? FUZEPATH . "/Application/Controller/" : $event->directory);
|
$this->directory = ($event->directory === null || empty($event->directory) ? FUZEPATH . "/Application/Controller/" : $event->directory);
|
||||||
|
|
||||||
// Load the controller
|
|
||||||
$this->loadController();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,6 +98,21 @@ class Router extends Bus {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function loadController() {
|
public function loadController() {
|
||||||
|
// Initate the controllerLoadEvent
|
||||||
|
$event = $this->events->fireEvent('controllerLoadEvent',
|
||||||
|
$this->route,
|
||||||
|
$this->controllerName,
|
||||||
|
$this->function,
|
||||||
|
$this->parameters,
|
||||||
|
$this->directory
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->route = ($event->route === null ? $this->route : $event->route);
|
||||||
|
$this->controllerName = ($event->controllerName === null ? $this->controllerName : $event->controllerName);
|
||||||
|
$this->function = ($event->function === null ? $this->function : $event->function);
|
||||||
|
$this->parameters = ($event->parameters === null ? $this->parameters : $event->parameters);
|
||||||
|
$this->directory = ($event->directory === null ? $this->directory : $event->directory);
|
||||||
|
|
||||||
$file = $this->directory . "controller.".strtolower($this->controllerName).".php";
|
$file = $this->directory . "controller.".strtolower($this->controllerName).".php";
|
||||||
$this->logger->log("Loading controller from file: '".$file."'");
|
$this->logger->log("Loading controller from file: '".$file."'");
|
||||||
|
|
||||||
|
@ -12,5 +12,6 @@ $core->init();
|
|||||||
$core->loadMod('router');
|
$core->loadMod('router');
|
||||||
$core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );
|
$core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );
|
||||||
$core->mods->router->route();
|
$core->mods->router->route();
|
||||||
|
$core->mods->router->loadController();
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user