* @return $debugInstance An instance of a debugger class
*/
public final static function createDebugInstance ($className) {
- // Init debug instance
- $debugInstance = NULL;
+ // Is the instance set?
+ if (!Registry::getRegistry()->instanceExists('debug')) {
+ // Init debug instance
+ $debugInstance = NULL;
+
+ // Try it
+ try {
+ // Get a debugger instance
+ $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
+ } catch (NullPointerException $e) {
+ // Didn't work, no instance there
+ exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
+ }
- // Try it
- try {
- // Get a debugger instance
- $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
- } catch (NullPointerException $e) {
- // Didn't work, no instance there
- exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
- }
+ // Empty string should be ignored and used for testing the middleware
+ DebugMiddleware::getSelfInstance()->output('');
- // Empty string should be ignored and used for testing the middleware
- DebugMiddleware::getSelfInstance()->output('');
+ // Set it in its own class. This will set it in the registry
+ $debugInstance->setDebugInstance($debugInstance);
+ } else {
+ // Get instance from registry
+ $debugInstance = Registry::getRegistry()->getDebugInstance();
+ }
// Return it
return $debugInstance;