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){
|
||||
if($directory === null){
|
||||
$directory = FUZEPATH . "/Application/Models";
|
||||
}
|
||||
// Model load event
|
||||
$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';
|
||||
if (isset($this->model_types[$name])) {
|
||||
|
@ -5,9 +5,10 @@ class Router extends Bus {
|
||||
public $controller = null;
|
||||
public $controllerName = null;
|
||||
public $function = null;
|
||||
private $route = array();
|
||||
private $parameters = array();
|
||||
private $path;
|
||||
public $route = array();
|
||||
public $parameters = array();
|
||||
public $directory;
|
||||
public $path;
|
||||
|
||||
public function __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->parameters = $event->parameters;
|
||||
$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
|
||||
*/
|
||||
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";
|
||||
$this->logger->log("Loading controller from file: '".$file."'");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user