// 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\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
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;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @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
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
- /**
- * Length of output from hash()
- */
- private static $hashLength = NULL;
-
/**
* Self-referencing instance
*/
* @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;
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
*
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
*
* @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
* @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
* @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
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];
}
* @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]);
}
* @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);