X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmiddleware%2Fdebug%2Fclass_DebugMiddleware.php;h=a275de113a3b9c01ecf3a74a1af2c983d729e341;hp=dec9b06f2e626dcb72f9363a74959d447d8d5296;hb=ffa33f1c07a894cad257eef2602afe09f29763ce;hpb=90608b0a257489c8da469af16a96007093dc1ffa diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php index dec9b06f..a275de11 100644 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -4,11 +4,11 @@ * become registered with this middleware because the back-fall class will * become deprecated soon. * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,12 +27,12 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { /** * The concrete output instance */ - private $outputInstance = null; + private $outputInstance = NULL; /** * An instance of this class */ - private static $thisInstance = null; + private static $selfInstance = NULL; /** * Protected constructor @@ -44,7 +44,10 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { parent::__construct(__CLASS__); // Set own instance - self::$thisInstance = $this; + self::$selfInstance = $this; + + // Set it so all can use it + $this->setDebugInstance($this); } /** @@ -52,26 +55,45 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { * If no output is given this class is currently being used for back-fall. * This fall-back mechanism will become deprecated very soon. * - * @param $debuggerClass The class name which we shall use for + * @param $outputClass The class name which we shall use for * registering the *real* debug output + * @param $className Class where a output should be created and + * configured for * @return $debugInstance An instance of this middleware class */ - public final static function createDebugMiddleware ($debuggerClass) { + public static final function createDebugMiddleware ($outputClass, $className) { + //* DEBUG-DIE: */ die(__METHOD__.': outputClass=' . $outputClass . ',className=' . $className); + // Create an instance if this middleware $debugInstance = new DebugMiddleware(); + // Default is that $outputClass may be invalid + $isInitialized = FALSE; + // Is there a valid output instance provided? - if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && ($debuggerClass instanceof OutputStreamer)) { + if ((!is_null($outputClass)) && (is_object($outputClass)) && ($outputClass instanceof OutputStreamer)) { // Use the given output instance - $debugInstance->setOutputInstance($debuggerClass); - } elseif ((!is_null($debuggerClass)) && (is_string($debuggerClass)) && (class_exists($debuggerClass))) { + $debugInstance->setOutputInstance($outputClass); + + // All fine + $isInitialized = TRUE; + } elseif ((!is_null($outputClass)) && (is_string($outputClass)) && (class_exists($outputClass))) { // A name for a debug output class has been provided so we try to get it - $debuggerInstance = ObjectFactory::createObjectByName($debuggerClass); + $outputInstance = ObjectFactory::createObjectByName($outputClass); // Set this as output class - $debugInstance->setOutputInstance($debuggerInstance); + $debugInstance->setOutputInstance($outputInstance); + + // All fine + $isInitialized = TRUE; } + // Is the output class initialized? + if ($isInitialized === TRUE) { + // Then set class name + $debugInstance->getOutputInstance()->setLoggerClassName($className); + } // END - if + // Return instance return $debugInstance; } @@ -79,10 +101,10 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { /** * Getter for an instance of this class * - * @return $thisInstance An instance of this class + * @return $selfInstance An instance of this class */ - public final static function getInstance() { - return self::$thisInstance; + public static final function getSelfInstance() { + return self::$selfInstance; } /** @@ -101,9 +123,10 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { * output instance. * * @param $outStream Data we shall 'stream' out to the world + * @param $stripTags Whether HTML tags shall be stripped out * @return void */ - public final function output ($outStream) { + public final function output ($outStream, $stripTags = FALSE) { // Is the output stream set if (empty($outStream)) { // @TODO Initialization phase @@ -111,7 +134,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { } // END - if // Use the output instance - $this->outputInstance->outputStream($outStream); + $this->outputInstance->outputStream($outStream, $stripTags); } }