X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=cc2a0d4498982baf8c96835228947e3ae33e4f82;hp=ac0d8362bbc15e304a2798dd004caad610fa6e92;hb=b9bfbe86c031c9d83c3670602906df191a33ba2a;hpb=e9e5242797adec674d25da4e641965f8d6dcbecd diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index ac0d8362..cc2a0d44 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -26,6 +26,7 @@ use CoreFramework\Generic\NullPointerException; use CoreFramework\Generic\UnsupportedOperationException; use CoreFramework\Handler\Handleable; use CoreFramework\Handler\Stream\IoHandler; +use CoreFramework\Helper\Helper; use CoreFramework\Index\Indexable; use CoreFramework\Lists\Listable; use CoreFramework\Loader\ClassLoader; @@ -51,6 +52,7 @@ use CoreFramework\Visitor\Visitor; use \stdClass; use \Iterator; use \ReflectionClass; +use \SplFileInfo; /** * The simulator system class is the super class of all other classes. This @@ -256,6 +258,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $stateInstance = NULL; + /** + * Registry instance (implementing Register) + */ + private $registryInstance = NULL; + + /** + * Call-back instance + */ + private $callbackInstance = NULL; + /** * Thousands separator */ @@ -1526,6 +1538,44 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->outputInstance; } + /** + * Setter for registry instance + * + * @param $registryInstance An instance of a Register class + * @return void + */ + protected final function setRegistryInstance (Register $registryInstance) { + $this->registryInstance = $registryInstance; + } + + /** + * Getter for registry instance + * + * @return $registryInstance The debug registry instance + */ + public final function getRegistryInstance () { + return $this->registryInstance; + } + + /** + * Setter for call-back instance + * + * @param $callbackInstance An instance of a FrameworkInterface class + * @return void + */ + public final function setCallbackInstance (FrameworkInterface $callbackInstance) { + $this->callbackInstance = $callbackInstance; + } + + /** + * Getter for call-back instance + * + * @return $callbackInstance An instance of a FrameworkInterface class + */ + protected final function getCallbackInstance () { + return $this->callbackInstance; + } + /** * Setter for command name * @@ -1700,7 +1750,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ); // Output it - ApplicationEntryPoint::app_exit(sprintf('
+ ApplicationEntryPoint::exitApplication(sprintf('
%s debug output:
@@ -1742,19 +1792,8 @@ Loaded includes: * @return void */ protected function partialStub ($message = '') { - // Get the backtrace - $backtrace = debug_backtrace(); - - // Generate the class::method string - $methodName = 'UnknownClass->unknownMethod'; - if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; - } // END - if - - // Construct the full message - $stubMessage = sprintf('[%s]: Partial stub!', - $methodName - ); + // Init variable + $stubMessage = 'Partial Stub!'; // Is the extra message given? if (!empty($message)) { @@ -1823,11 +1862,11 @@ Loaded includes: // 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); + // Set it in registry + Registry::getRegistry()->addInstance('debug', $debugInstance); } else { // Get instance from registry - $debugInstance = Registry::getRegistry()->getDebugInstance(); + $debugInstance = Registry::getRegistry()->getInstance('debug'); } // Return it @@ -1859,6 +1898,28 @@ Loaded includes: // Set debug instance to NULL $debugInstance = NULL; + // Get backtrace + $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT); + + // Is function partialStub/__callStatic ? + if (in_array($backtrace[1]['function'], array('partialStub', '__call', '__callStatic'))) { + // Prepend class::function:line from 3rd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[2]['class'], + $backtrace[2]['function'], + (isset($backtrace[2]['line']) ? $backtrace[2]['line'] : '0'), + $message + ); + } else { + // Prepend class::function:line from 2nd element + $message = sprintf('[%s::%s:%d]: %s', + $backtrace[1]['class'], + $backtrace[1]['function'], + (isset($backtrace[1]['line']) ? $backtrace[1]['line'] : '0'), + $message + ); + } + // Try it: try { // Get debug instance @@ -3217,32 +3278,32 @@ Loaded includes: * Creates a full-qualified file name (FQFN) for given file name by adding * a configured temporary file path to it. * - * @param $fileName Name for temporary file - * @return $fqfn Full-qualified file name + * @param $infoInstance An instance of a SplFileInfo class + * @return $tempInstance An instance of a SplFileInfo class (temporary file) * @throw PathWriteProtectedException If the path in 'temp_file_path' is write-protected * @throws FileIoException If the file cannot be written */ - protected static function createTempPathForFile ($fileName) { + protected static function createTempPathForFile (SplFileInfo $infoInstance) { // Get config entry $basePath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('temp_file_path'); // Is the path writeable? if (!is_writable($basePath)) { // Path is write-protected - throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); + throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); } // END - if // Add it - $fqfn = $basePath . DIRECTORY_SEPARATOR . $fileName; + $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename()); // Is it reachable? - if (!FrameworkBootstrap::isReachableFilePath($fqfn)) { + if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) { // Not reachable - throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_REACHABLE); + throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE); } // END - if // Return it - return $fqfn; + return $tempInstance; } /**