diff --git a/Core/Events/event.controllerLoadEvent.php b/Core/Events/event.controllerLoadEvent.php new file mode 100644 index 0000000..63d3553 --- /dev/null +++ b/Core/Events/event.controllerLoadEvent.php @@ -0,0 +1,20 @@ +route = $route; + $this->controllerName = $controllerName; + $this->function = $function; + $this->parameters = $parameters; + $this->directory = $directory; + } +} + +?> \ No newline at end of file diff --git a/Core/Events/event.modelLoadEvent.php b/Core/Events/event.modelLoadEvent.php new file mode 100644 index 0000000..0c8f0ce --- /dev/null +++ b/Core/Events/event.modelLoadEvent.php @@ -0,0 +1,13 @@ +model = $model; + } +} + +?> \ No newline at end of file diff --git a/Core/System/class.models.php b/Core/System/class.models.php index 0abf1e0..1e4b574 100644 --- a/Core/System/class.models.php +++ b/Core/System/class.models.php @@ -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])) { diff --git a/Modules/router/class.router.php b/Modules/router/class.router.php index 1b1c7a4..e7208d5 100644 --- a/Modules/router/class.router.php +++ b/Modules/router/class.router.php @@ -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."'"); diff --git a/index.php b/index.php index 4053923..5d28680 100644 --- a/index.php +++ b/index.php @@ -12,5 +12,6 @@ $core->init(); $core->loadMod('router'); $core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) ); $core->mods->router->route(); +$core->mods->router->loadController(); ?> \ No newline at end of file