Skip to content

Commit

Permalink
Adding autoload_controller feature autoload_controller(['function']);
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice Luraine committed Feb 4, 2010
1 parent 12f943f commit c8a6f10
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/limonade.php
Expand Up @@ -171,6 +171,7 @@ function render_limonade_file()
## ABSTRACTS ___________________________________________________________________

# function configure(){}
# function autoload_controller(){}
# function before(){}
# function after(){}
# function not_found(){}
Expand Down Expand Up @@ -389,7 +390,14 @@ function route_missing($request_method, $request_uri)
params($route['params']);

# 6.2 Load controllers dir
require_once_dir(option('controllers_dir'));
if(!function_exists('autoload_controller'))
{
function autoload_controller($callback)
{
require_once_dir(option('controllers_dir'));
}
}
autoload_controller($route['function']);

if(is_callable($route['function']))
{
Expand Down
20 changes: 20 additions & 0 deletions lib/limonade/abstract.php
Expand Up @@ -19,6 +19,26 @@ function configure()
{
return;
}

/**
* Called in run() just after the route matching, in order to load controllers.
* If not specfied, the default function is called:
*
* <code>
* function autoload_controller($callback)
* {
* require_once_dir(option('controllers_dir'));
* }
* </code>
*
*
* @param string $callback the callback deined in matching route
* @return void
*/
function autoload_controller($callback)
{
return;
}

/**
* Called before each request.
Expand Down

0 comments on commit c8a6f10

Please sign in to comment.