X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=38a45f3de6487ae05416f5e7fbff5ab4508723ec;hb=08a0c865dd2c8ee0b6dbf96f4f07e9ee0ce0f02b;hp=526346cacc65ecae92248aecf79338a3160a0979;hpb=98ced4f4bc205820b42b6e09f9255792fdf6fcb5;p=core.git diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 526346ca..38a45f3d 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -4,9 +4,8 @@ namespace Org\Mxchange\CoreFramework\Object; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Criteria\Criteria; use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; -use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; @@ -19,7 +18,7 @@ use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult; use Org\Mxchange\CoreFramework\State\Stateable; use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer; -use Org\Mxchange\CoreFramework\Utils\String\StringUtils; +use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils; // Import SPL stuff use \stdClass; @@ -33,7 +32,7 @@ use \SplFileInfo; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -51,11 +50,6 @@ use \SplFileInfo; * along with this program. If not, see . */ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterface { - /** - * Length of output from hash() - */ - private static $hashLength = NULL; - /** * Self-referencing instance */ @@ -618,8 +612,11 @@ Loaded includes: * @deprecated Not fully, as the new Logger facilities are not finished yet. */ public final static function createDebugInstance (string $className, int $lineNumber = NULL) { - // Is the instance set? - if (!GenericRegistry::getRegistry()->instanceExists('debug')) { + // Validate parameter + if (empty($className)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "className" is empty'); + } elseif (!GenericRegistry::getRegistry()->instanceExists('debug')) { // Init debug instance $debugInstance = NULL; @@ -629,7 +626,7 @@ Loaded includes: $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className); } catch (NullPointerException $e) { // Didn't work, no instance there - exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber)); + exit(sprintf('[%s:%d]: Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, __METHOD__, __LINE__, $e->__toString(), $e->getMessage(), $className, $lineNumber)); } // Empty string should be ignored and used for testing the middleware @@ -968,26 +965,6 @@ Loaded includes: return $isBase64; } - /** - * Gets a cache key from Criteria instance - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey A cache key suitable for lookup/storage purposes - */ - protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { - // Generate it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: criteriaInstance=' . $criteriaInstance->__toString() . ',onlyKeys()=' . count($onlyKeys) . ' - CALLED!'); - $cacheKey = sprintf('%s@%s', - $this->__toString(), - $criteriaInstance->getCacheKey($onlyKeys) - ); - - // And return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: cacheKey=' . $cacheKey . ' - EXIT!'); - return $cacheKey; - } - /** * Getter for startup time in miliseconds * @@ -1003,48 +980,13 @@ Loaded includes: * @return $executionTime Current execution time in nice braces */ protected function getPrintableExecutionTime () { - // Caculate the execution time - $executionTime = microtime(true) - $this->getStartupTime(); - - // Pack it in nice braces - $executionTime = sprintf('[ %01.5f ] ', $executionTime); + // Calculate execution time and pack it in nice braces + $executionTime = sprintf('[ %01.5f ] ', (microtime(true) - $this->getStartupTime())); // And return it return $executionTime; } - /** - * Hashes a given string with a simple but stronger hash function (no salt) - * and hex-encode it. - * - * @param $str The string to be hashed - * @return $hash The hash from string $str - */ - public static final function hash (string $str) { - // Hash given string with (better secure) hasher - $hash = bin2hex(mhash(MHASH_SHA256, $str)); - - // Return it - return $hash; - } - - /** - * "Getter" for length of hash() output. This will be "cached" to speed up - * things. - * - * @return $length Length of hash() output - */ - public static final function getHashLength () { - // Is it cashed? - if (is_null(self::$hashLength)) { - // No, then hash a string and save its length. - self::$hashLength = strlen(self::hash('abc123')); - } - - // Return it - return self::$hashLength; - } - /** * Determines if an element is set in the generic array * @@ -1055,10 +997,8 @@ Loaded includes: * @return $isset Whether the given key is set */ protected final function isGenericArrayElementSet (string $keyGroup, string $subGroup, $key, $element) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); - // Is it there? + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]); // Return it @@ -1073,10 +1013,8 @@ Loaded includes: * @return $isset Whether the given key is set */ protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - // Is it there? + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]); // Return it @@ -1092,10 +1030,8 @@ Loaded includes: * @return $isset Whether the given group is set */ protected final function isGenericArrayGroupSet (string $keyGroup, string $subGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); - // Is it there? + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); $isset = isset($this->genericArray[$keyGroup][$subGroup]); // Return it @@ -1117,10 +1053,8 @@ Loaded includes: exit; } - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], true)); - // Return it + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], true)); return $this->genericArray[$keyGroup][$subGroup]; } @@ -1133,10 +1067,8 @@ Loaded includes: * @return void */ protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - // Remove it + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); unset($this->genericArray[$keyGroup][$subGroup][$key]); } @@ -1642,11 +1574,8 @@ Loaded includes: * @return void */ protected function initWebOutputInstance () { - // Get application instance - $applicationInstance = ApplicationHelper::getSelfInstance(); - // Init web output instance - $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); + $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class'); // Set it locally $this->setWebOutputInstance($outputInstance);