Skip to content
Snippets Groups Projects
Commit 600fb65e authored by Andreas Gohr's avatar Andreas Gohr
Browse files

autoload plugin namespace

This introduces an autoloader for namespaces starting with plugin\*

This way, plugins can easily have additional classes auto loaded without
needing to register their own loader. A plugin\*\test\* namespace will
automatically be mapped to the _test directory of the plugin.
parent 7468fb90
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,16 @@ function load_autoload($name){
return true;
}
// plugin namespace
if(substr($name, 0, 7) == 'plugin/') {
$name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
$file = DOKU_PLUGIN . substr($name, 7) . '.php';
if(file_exists($file)) {
require $file;
return true;
}
}
// Plugin loading
if(preg_match('/^(auth|helper|syntax|action|admin|renderer|remote)_plugin_('.DOKU_PLUGIN_NAME_REGEX.')(?:_([^_]+))?$/',
$name, $m)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment