Skip to content

Instantly share code, notes, and snippets.

@TheOpenDevProject
Created July 2, 2015 11:03
Show Gist options
  • Save TheOpenDevProject/0b90e7eb20af1e0f3897 to your computer and use it in GitHub Desktop.
Save TheOpenDevProject/0b90e7eb20af1e0f3897 to your computer and use it in GitHub Desktop.
//Snippet from router
$callerArgs = func_get_args();
//Offset our args to forward by one, the plugin should not be aware of the URL that was requested.
$subUrlArgs = array_slice($callerArgs, 1);
//Try to create an instance of the class
$plugin = PluginLoader::LoadPlugin("SimpleMail");
$pluginInstance = $plugin->newInstanceArgs(array(true));
$pluginInstance->exec();
//Object Oriented plugins FOR THE WIN!
class PluginLoader{
public static function LoadPlugin($pluginName){
try{
$plugin = new ReflectionClass($pluginName);
return $plugin;
}catch(Exception $ex){
throw new Exception("There was a problem loading the plugin." .$ex->getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment