Skip to content

Instantly share code, notes, and snippets.

@mapkyca
Created January 8, 2015 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapkyca/f00a0f3ac9879b77d8c7 to your computer and use it in GitHub Desktop.
Save mapkyca/f00a0f3ac9879b77d8c7 to your computer and use it in GitHub Desktop.
Plugin autoloader for Known plugin repos
/**
* Support loading of direct checkout.
*/
spl_autoload_register(function($class) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$segments = explode(DIRECTORY_SEPARATOR, $class);
$PLUGIN_NAME = $segments[1];
$basedir = dirname(dirname(dirname(__FILE__))) . '/';
$file = str_replace($PLUGIN_NAME, basename(dirname(__FILE__)) . "/$PLUGIN_NAME", $class);
\Idno\Core\site()->plugins()->plugins[basename(dirname(__FILE__))] = \Idno\Core\site()->plugins()->plugins[$PLUGIN_NAME];
unset(\Idno\Core\site()->plugins()->plugins[$PLUGIN_NAME]);
if (file_exists($basedir . $file . '.php')) {
include_once($basedir . $file . '.php');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment