Created
July 2, 2015 11:03
-
-
Save TheOpenDevProject/0b90e7eb20af1e0f3897 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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