X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=dc2410c324d9991d2e8a4b91f5a4c7c791cd87e7;hb=f861d6bc00f8a3ecf6b057f2aa93129572643896;hp=322bd28263da9984da6176ce53c2c31516f32a58;hpb=b954ccaa3dbfc59ddc76e463d2980a5dc204cc9f;p=core.git
diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php
index 322bd282..dc2410c3 100644
--- a/framework/main/classes/class_BaseFrameworkSystem.php
+++ b/framework/main/classes/class_BaseFrameworkSystem.php
@@ -1,57 +1,32 @@
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
@@ -76,264 +51,40 @@ use \ReflectionClass;
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
- /**
- * Length of output from hash()
- */
- private static $hashLength = NULL;
-
- /**
- * The real class name
- */
- private $realClass = 'BaseFrameworkSystem';
-
- /**
- * Search criteria instance
- */
- private $searchInstance = NULL;
-
- /**
- * Update criteria instance
- */
- private $updateInstance = NULL;
-
- /**
- * The file I/O instance for the template loader
- */
- private $fileIoInstance = NULL;
-
- /**
- * Resolver instance
- */
- private $resolverInstance = NULL;
-
- /**
- * Template engine instance
- */
- private $templateInstance = NULL;
-
- /**
- * Database result instance
- */
- private $resultInstance = NULL;
-
- /**
- * Instance for user class
- */
- private $userInstance = NULL;
-
- /**
- * A controller instance
- */
- private $controllerInstance = NULL;
-
- /**
- * Instance of a RNG
- */
- private $rngInstance = NULL;
-
- /**
- * Instance of a crypto helper
- */
- private $cryptoInstance = NULL;
-
- /**
- * Instance of an Iterator class
- */
- private $iteratorInstance = NULL;
-
- /**
- * Instance of the list
- */
- private $listInstance = NULL;
-
- /**
- * Instance of a menu
- */
- private $menuInstance = NULL;
-
- /**
- * Instance of the image
- */
- private $imageInstance = NULL;
-
- /**
- * Instance of the stacker
- */
- private $stackInstance = NULL;
-
- /**
- * A Compressor instance
- */
- private $compressorInstance = NULL;
-
- /**
- * A Parseable instance
- */
- private $parserInstance = NULL;
-
- /**
- * A database wrapper instance
- */
- private $databaseInstance = NULL;
-
- /**
- * A helper instance for the form
- */
- private $helperInstance = NULL;
-
- /**
- * An instance of a Source class
- */
- private $sourceInstance = NULL;
-
- /**
- * An instance of a UrlSource class
- */
- private $urlSourceInstance = NULL;
-
- /**
- * An instance of a InputStream class
- */
- private $inputStreamInstance = NULL;
-
- /**
- * An instance of a OutputStream class
- */
- private $outputStreamInstance = NULL;
-
- /**
- * Handler instance
- */
- private $handlerInstance = NULL;
-
- /**
- * Visitor handler instance
- */
- private $visitorInstance = NULL;
-
- /**
- * An instance of a database wrapper class
- */
- private $wrapperInstance = NULL;
-
- /**
- * An instance of a file I/O pointer class (not handler)
- */
- private $pointerInstance = NULL;
-
- /**
- * An instance of an Indexable class
- */
- private $indexInstance = NULL;
-
- /**
- * An instance of a Block class
- */
- private $blockInstance = NULL;
-
+abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
/**
- * A Minable instance
+ * Self-referencing instance
*/
- private $minableInstance = NULL;
+ private static $selfInstance = NULL;
/**
- * A FrameworkDirectory instance
+ * Debug instance
*/
- private $directoryInstance = NULL;
+ private static $debugInstance = NULL;
/**
- * An instance of a communicator
+ * Stub methods
*/
- private $communicatorInstance = NULL;
+ private static $stubMethods = [
+ 'partialStub' => true,
+ '__call' => true,
+ '__callStatic' => true,
+ ];
/**
- * The concrete output instance
- */
- private $outputInstance = NULL;
-
- /**
- * State instance
- */
- private $stateInstance = NULL;
-
- /**
- * Registry instance (implementing Register)
+ * The real class name
*/
- private $registryInstance = NULL;
+ private $realClass = __CLASS__;
/**
* Call-back instance
*/
private $callbackInstance = NULL;
- /**
- * Thousands separator
- */
- private $thousands = '.'; // German
-
- /**
- * Decimal separator
- */
- private $decimals = ','; // German
-
- /**
- * Socket resource
- */
- private $socketResource = false;
-
- /**
- * Regular expression to use for validation
- */
- private $regularExpression = '';
-
- /**
- * Package data
- */
- private $packageData = array();
-
/**
* Generic array
*/
- private $genericArray = array();
-
- /**
- * Command name
- */
- private $commandName = '';
-
- /**
- * Controller name
- */
- private $controllerName = '';
-
- /**
- * Array with bitmasks and such for pack/unpack methods to support both
- * 32-bit and 64-bit systems
- */
- private $packingData = array(
- 32 => array(
- 'step' => 3,
- 'left' => 0xffff0000,
- 'right' => 0x0000ffff,
- 'factor' => 16,
- 'format' => 'II',
- ),
- 64 => array(
- 'step' => 7,
- 'left' => 0xffffffff00000000,
- 'right' => 0x00000000ffffffff,
- 'factor' => 32,
- 'format' => 'NN'
- )
- );
-
- /**
- * Simple 64-bit check, thanks to "Salman A" from stackoverflow.com:
- *
- * The integer size is 4 bytes on 32-bit and 8 bytes on a 64-bit system.
- */
- private $archArrayElement = false;
+ private $genericArray = [];
/***********************
* Exception codes.... *
@@ -385,67 +136,23 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b;
const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c;
const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d;
- const EXCEPTION_UNSPPORTED_OPERATION = 0x02e;
- const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02f;
- const EXCEPTION_MISSING_ELEMENT = 0x030;
- const EXCEPTION_HEADERS_ALREADY_SENT = 0x031;
- const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032;
- const EXCEPTION_CLASS_NOT_FOUND = 0x033;
- const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x034;
- const EXCEPTION_FATAL_ERROR = 0x035;
- const EXCEPTION_FILE_NOT_FOUND = 0x036;
- const EXCEPTION_ASSERTION_FAILED = 0x037;
- const EXCEPTION_FILE_NOT_REACHABLE = 0x038;
- const EXCEPTION_FILE_CANNOT_BE_READ = 0x039;
- const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x03a;
- const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03b;
- const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c;
- const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d;
- const EXCEPTION_INVALID_SOCKET = 0x03e;
-
- /**
- * Hexadecimal->Decimal translation array
- */
- private static $hexdec = array(
- '0' => 0,
- '1' => 1,
- '2' => 2,
- '3' => 3,
- '4' => 4,
- '5' => 5,
- '6' => 6,
- '7' => 7,
- '8' => 8,
- '9' => 9,
- 'a' => 10,
- 'b' => 11,
- 'c' => 12,
- 'd' => 13,
- 'e' => 14,
- 'f' => 15
- );
-
- /**
- * Decimal->hexadecimal translation array
- */
- private static $dechex = array(
- 0 => '0',
- 1 => '1',
- 2 => '2',
- 3 => '3',
- 4 => '4',
- 5 => '5',
- 6 => '6',
- 7 => '7',
- 8 => '8',
- 9 => '9',
- 10 => 'a',
- 11 => 'b',
- 12 => 'c',
- 13 => 'd',
- 14 => 'e',
- 15 => 'f'
- );
+ const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02e;
+ const EXCEPTION_MISSING_ELEMENT = 0x02f;
+ const EXCEPTION_HEADERS_ALREADY_SENT = 0x030;
+ const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x031;
+ const EXCEPTION_CLASS_NOT_FOUND = 0x032;
+ const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x033;
+ const EXCEPTION_FATAL_ERROR = 0x034;
+ const EXCEPTION_FILE_NOT_FOUND = 0x035;
+ const EXCEPTION_ASSERTION_FAILED = 0x036;
+ const EXCEPTION_FILE_NOT_REACHABLE = 0x037;
+ const EXCEPTION_FILE_CANNOT_BE_READ = 0x038;
+ const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x039;
+ const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03a;
+ const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03b;
+ const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03c;
+ const EXCEPTION_INVALID_SOCKET = 0x03d;
+ const EXCEPTION_SELF_INSTANCE = 0x03e;
/**
* Startup time in miliseconds
@@ -458,24 +165,15 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $className Name of the class
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Set real class
$this->setRealClass($className);
- // Set configuration instance if no registry ...
- if (!$this instanceof Register) {
- // ... because registries doesn't need to be configured
- $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
- } // END - if
-
// Is the startup time set? (0 cannot be true anymore)
if (self::$startupTime == 0) {
// Then set it
self::$startupTime = microtime(true);
- } // END - if
-
- // Set array element
- $this->archArrayElement = (PHP_INT_SIZE === 8 ? 64 : 32);
+ }
}
/**
@@ -484,22 +182,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return void
*/
public function __destruct () {
- // Flush any updated entries to the database
- $this->flushPendingUpdates();
-
// Is this object already destroyed?
if ($this->__toString() != 'DestructedObject') {
// Destroy all informations about this class but keep some text about it alive
$this->setRealClass('DestructedObject');
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('The object %s is already destroyed.',
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('The object %s is already destroyed.',
$this->__toString()
));
} else {
// Do not call this twice
trigger_error(__METHOD__ . ': Called twice.');
- exit;
+ exit(255);
}
}
@@ -510,23 +205,39 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @args $args Arguments passed to the method
* @return void
*/
- public final function __call ($methodName, $args) {
- return self::__callStatic($methodName, $args);
+ public final function __call (string $methodName, array $args = NULL) {
+ // Set self-instance
+ self::$selfInstance = $this;
+
+ // Call static method
+ self::__callStatic($methodName, $args);
+
+ // Clear self-instance
+ self::$selfInstance = NULL;
}
/**
* The __callStatic() method where all non-implemented static methods end up
*
* @param $methodName Name of the missing method
- * @args $args Arguments passed to the method
+ * @param $args Arguments passed to the method
* @return void
+ * @throws InvalidArgumentException If self::$selfInstance is not a framework's own object
*/
- public static final function __callStatic ($methodName, $args) {
- // Trace message
+ public static final function __callStatic (string $methodName, array $args = NULL) {
+ // Init argument string and class name
//* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args));
-
- // Init argument string
$argsString = '';
+ $className = 'unknown';
+
+ // Is self-instance set?
+ if (self::$selfInstance instanceof FrameworkInterface) {
+ // Framework's own instance
+ $className = self::$selfInstance->__toString();
+ } elseif (!is_null(self::$selfInstance)) {
+ // Invalid argument!
+ throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$selfInstance)), self::EXCEPTION_SELF_INSTANCE);
+ }
// Is it NULL, empty or an array?
if (is_null($args)) {
@@ -569,23 +280,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
// Comma for next one
$argsString .= ', ';
- } // END - foreach
+ }
- // Remove last comma
+ // Last comma found?
if (substr($argsString, -2, 1) == ',') {
+ // Remove last comma
$argsString = substr($argsString, 0, -2);
- } // END - if
+ }
// Close braces
$argsString .= ')';
- } else {
- // Invalid arguments!
- $argsString = '!INVALID:' . gettype($args) . '!';
}
// Output stub message
// @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s]: Stub! Args: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('[%s::%s]: Stub! Args: %s',
+ $className,
$methodName,
$argsString
));
@@ -610,7 +320,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $value Value to store
* @return void
*/
- public final function __set ($name, $value) {
+ public final function __set (string $name, $value) {
$this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s',
$name,
gettype($value),
@@ -624,7 +334,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $name Name of the field/attribute
* @return void
*/
- public final function __get ($name) {
+ public final function __get (string $name) {
$this->debugBackTrace(sprintf('Tried to get a missing field. name=%s',
$name
));
@@ -636,7 +346,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $name Name of the field/attribute
* @return void
*/
- public final function __unset ($name) {
+ public final function __unset (string $name) {
$this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s',
$name
));
@@ -649,7 +359,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __sleep () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
@@ -659,7 +369,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __wakeup () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
@@ -669,7 +379,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __invoke () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
@@ -678,126 +388,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @param $realClass Class name (string)
* @return void
*/
- public final function setRealClass ($realClass) {
+ public final function setRealClass (string $realClass) {
// Set real class
- $this->realClass = (string) $realClass;
- }
-
- /**
- * Setter for database result instance
- *
- * @param $resultInstance An instance of a database result class
- * @return void
- * @todo SearchableResult and UpdateableResult shall have a super interface to use here
- */
- protected final function setResultInstance (SearchableResult $resultInstance) {
- $this->resultInstance = $resultInstance;
- }
-
- /**
- * Getter for database result instance
- *
- * @return $resultInstance An instance of a database result class
- */
- public final function getResultInstance () {
- return $this->resultInstance;
- }
-
- /**
- * Setter for template engine instances
- *
- * @param $templateInstance An instance of a template engine class
- * @return void
- */
- protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
- $this->templateInstance = $templateInstance;
- }
-
- /**
- * Getter for template engine instances
- *
- * @return $templateInstance An instance of a template engine class
- */
- protected final function getTemplateInstance () {
- return $this->templateInstance;
- }
-
- /**
- * Setter for search instance
- *
- * @param $searchInstance Searchable criteria instance
- * @return void
- */
- public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
- $this->searchInstance = $searchInstance;
- }
-
- /**
- * Getter for search instance
- *
- * @return $searchInstance Searchable criteria instance
- */
- public final function getSearchInstance () {
- return $this->searchInstance;
- }
-
- /**
- * Setter for update instance
- *
- * @param $updateInstance An instance of a LocalUpdateCriteria clase
- * @return void
- */
- public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
- $this->updateInstance = $updateInstance;
- }
-
- /**
- * Getter for update instance
- *
- * @return $updateInstance Updateable criteria instance
- */
- public final function getUpdateInstance () {
- return $this->updateInstance;
- }
-
- /**
- * Setter for resolver instance
- *
- * @param $resolverInstance Instance of a command resolver class
- * @return void
- */
- public final function setResolverInstance (Resolver $resolverInstance) {
- $this->resolverInstance = $resolverInstance;
- }
-
- /**
- * Getter for resolver instance
- *
- * @return $resolverInstance Instance of a command resolver class
- */
- public final function getResolverInstance () {
- return $this->resolverInstance;
- }
-
- /**
- * Setter for language instance
- *
- * @param $configInstance The configuration instance which shall
- * be FrameworkConfiguration
- * @return void
- */
- public final function setConfigInstance (FrameworkConfiguration $configInstance) {
- Registry::getRegistry()->addInstance('config', $configInstance);
- }
-
- /**
- * Getter for configuration instance
- *
- * @return $configInstance Configuration instance
- */
- public final function getConfigInstance () {
- $configInstance = Registry::getRegistry()->getInstance('config');
- return $configInstance;
+ $this->realClass = $realClass;
}
/**
@@ -807,7 +400,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return void
*/
public final function setDebugInstance (DebugMiddleware $debugInstance) {
- Registry::getRegistry()->addInstance('debug', $debugInstance);
+ self::$debugInstance = $debugInstance;
}
/**
@@ -816,11 +409,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput
*/
public final function getDebugInstance () {
- // Get debug instance
- $debugInstance = Registry::getRegistry()->getInstance('debug');
-
- // Return it
- return $debugInstance;
+ return self::$debugInstance;
}
/**
@@ -830,7 +419,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return void
*/
public final function setWebOutputInstance (OutputStreamer $webInstance) {
- Registry::getRegistry()->addInstance('web_output', $webInstance);
+ GenericRegistry::getRegistry()->addInstance('web_output', $webInstance);
}
/**
@@ -839,894 +428,83 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
* @return $webOutputInstance - Instance to class WebOutput
*/
public final function getWebOutputInstance () {
- $webOutputInstance = Registry::getRegistry()->getInstance('web_output');
- return $webOutputInstance;
+ return GenericRegistry::getRegistry()->getInstance('web_output');
}
/**
- * Setter for database instance
+ * Setter for call-back instance
*
- * @param $databaseInstance The instance for the database connection (forced DatabaseConnection)
+ * @param $callbackInstance An instance of a FrameworkInterface class
* @return void
*/
- public final function setDatabaseInstance (DatabaseConnection $databaseInstance) {
- Registry::getRegistry()->addInstance('db_instance', $databaseInstance);
+ public final function setCallbackInstance (FrameworkInterface $callbackInstance) {
+ $this->callbackInstance = $callbackInstance;
}
/**
- * Getter for database layer
+ * Getter for call-back instance
*
- * @return $databaseInstance The database layer instance
+ * @return $callbackInstance An instance of a FrameworkInterface class
*/
- public final function getDatabaseInstance () {
- // Get instance
- $databaseInstance = Registry::getRegistry()->getInstance('db_instance');
-
- // Return instance
- return $databaseInstance;
+ protected final function getCallbackInstance () {
+ return $this->callbackInstance;
}
/**
- * Setter for compressor channel
+ * Checks whether an object equals this object. You should overwrite this
+ * method to implement own equality checks
*
- * @param $compressorInstance An instance of CompressorChannel
- * @return void
+ * @param $objectInstance An instance of a FrameworkInterface object
+ * @return $equals Whether both objects equals
*/
- public final function setCompressorChannel (CompressorChannel $compressorInstance) {
- Registry::getRegistry()->addInstance('compressor', $compressorInstance);
+ public function equals (FrameworkInterface $objectInstance) {
+ // Now test it
+ $equals = ((
+ $this->__toString() == $objectInstance->__toString()
+ ) && (
+ $this->hashCode() == $objectInstance->hashCode()
+ ));
+
+ // Return the result
+ return $equals;
}
/**
- * Getter for compressor channel
+ * Generates a generic hash code of this class. You should really overwrite
+ * this method with your own hash code generator code. But keep KISS in mind.
*
- * @return $compressorInstance The compressor channel
+ * @return $hashCode A generic hash code respresenting this whole class
*/
- public final function getCompressorChannel () {
- $compressorInstance = Registry::getRegistry()->getInstance('compressor');
- return $compressorInstance;
+ public function hashCode () {
+ // Simple hash code
+ return crc32($this->__toString());
}
/**
- * Protected getter for a manageable application helper class
+ * Appends a trailing slash to a string
*
- * @return $applicationInstance An instance of a manageable application helper class
+ * @param $str A string (maybe) without trailing slash
+ * @return $str A string with an auto-appended trailing slash
*/
- protected final function getApplicationInstance () {
- $applicationInstance = Registry::getRegistry()->getInstance('app');
- return $applicationInstance;
+ public final function addMissingTrailingSlash (string $str) {
+ // Is there a trailing slash?
+ if (substr($str, -1, 1) != '/') {
+ $str .= '/';
+ }
+
+ // Return string with trailing slash
+ return $str;
}
/**
- * Setter for a manageable application helper class
+ * Debugs this instance by putting out it's full content
*
- * @param $applicationInstance An instance of a manageable application helper class
+ * @param $message Optional message to show in debug output
* @return void
*/
- public final function setApplicationInstance (ManageableApplication $applicationInstance) {
- Registry::getRegistry()->addInstance('application', $applicationInstance);
- }
-
- /**
- * Private getter for language instance
- *
- * @return $langInstance An instance to the language sub-system
- */
- protected final function getLanguageInstance () {
- $langInstance = Registry::getRegistry()->getInstance('language');
- return $langInstance;
- }
-
- /**
- * Setter for language instance
- *
- * @param $langInstance An instance to the language sub-system
- * @return void
- * @see LanguageSystem
- */
- public final function setLanguageInstance (ManageableLanguage $langInstance) {
- Registry::getRegistry()->addInstance('language', $langInstance);
- }
-
- /**
- * Private getter for file IO instance
- *
- * @return $fileIoInstance An instance to the file I/O sub-system
- */
- protected final function getFileIoInstance () {
- return $this->fileIoInstance;
- }
-
- /**
- * Setter for file I/O instance
- *
- * @param $fileIoInstance An instance to the file I/O sub-system
- * @return void
- */
- public final function setFileIoInstance (IoHandler $fileIoInstance) {
- $this->fileIoInstance = $fileIoInstance;
- }
-
- /**
- * Protected setter for user instance
- *
- * @param $userInstance An instance of a user class
- * @return void
- */
- protected final function setUserInstance (ManageableAccount $userInstance) {
- $this->userInstance = $userInstance;
- }
-
- /**
- * Getter for user instance
- *
- * @return $userInstance An instance of a user class
- */
- public final function getUserInstance () {
- return $this->userInstance;
- }
-
- /**
- * Setter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @param $controllerInstance An instance of the controller
- * @return void
- */
- public final function setControllerInstance (Controller $controllerInstance) {
- $this->controllerInstance = $controllerInstance;
- }
-
- /**
- * Getter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @return $controllerInstance An instance of the controller
- */
- public final function getControllerInstance () {
- return $this->controllerInstance;
- }
-
- /**
- * Setter for RNG instance
- *
- * @param $rngInstance An instance of a random number generator (RNG)
- * @return void
- */
- protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
- $this->rngInstance = $rngInstance;
- }
-
- /**
- * Getter for RNG instance
- *
- * @return $rngInstance An instance of a random number generator (RNG)
- */
- public final function getRngInstance () {
- return $this->rngInstance;
- }
-
- /**
- * Setter for Cryptable instance
- *
- * @param $cryptoInstance An instance of a Cryptable class
- * @return void
- */
- protected final function setCryptoInstance (Cryptable $cryptoInstance) {
- $this->cryptoInstance = $cryptoInstance;
- }
-
- /**
- * Getter for Cryptable instance
- *
- * @return $cryptoInstance An instance of a Cryptable class
- */
- public final function getCryptoInstance () {
- return $this->cryptoInstance;
- }
-
- /**
- * Setter for the list instance
- *
- * @param $listInstance A list of Listable
- * @return void
- */
- protected final function setListInstance (Listable $listInstance) {
- $this->listInstance = $listInstance;
- }
-
- /**
- * Getter for the list instance
- *
- * @return $listInstance A list of Listable
- */
- protected final function getListInstance () {
- return $this->listInstance;
- }
-
- /**
- * Setter for the menu instance
- *
- * @param $menuInstance A RenderableMenu instance
- * @return void
- */
- protected final function setMenuInstance (RenderableMenu $menuInstance) {
- $this->menuInstance = $menuInstance;
- }
-
- /**
- * Getter for the menu instance
- *
- * @return $menuInstance A RenderableMenu instance
- */
- protected final function getMenuInstance () {
- return $this->menuInstance;
- }
-
- /**
- * Setter for image instance
- *
- * @param $imageInstance An instance of an image
- * @return void
- */
- public final function setImageInstance (BaseImage $imageInstance) {
- $this->imageInstance = $imageInstance;
- }
-
- /**
- * Getter for image instance
- *
- * @return $imageInstance An instance of an image
- */
- public final function getImageInstance () {
- return $this->imageInstance;
- }
-
- /**
- * Setter for stacker instance
- *
- * @param $stackInstance An instance of an stacker
- * @return void
- */
- public final function setStackInstance (Stackable $stackInstance) {
- $this->stackInstance = $stackInstance;
- }
-
- /**
- * Getter for stacker instance
- *
- * @return $stackInstance An instance of an stacker
- */
- public final function getStackInstance () {
- return $this->stackInstance;
- }
-
- /**
- * Setter for compressor instance
- *
- * @param $compressorInstance An instance of an compressor
- * @return void
- */
- public final function setCompressorInstance (Compressor $compressorInstance) {
- $this->compressorInstance = $compressorInstance;
- }
-
- /**
- * Getter for compressor instance
- *
- * @return $compressorInstance An instance of an compressor
- */
- public final function getCompressorInstance () {
- return $this->compressorInstance;
- }
-
- /**
- * Setter for Parseable instance
- *
- * @param $parserInstance An instance of an Parseable
- * @return void
- */
- public final function setParserInstance (Parseable $parserInstance) {
- $this->parserInstance = $parserInstance;
- }
-
- /**
- * Getter for Parseable instance
- *
- * @return $parserInstance An instance of an Parseable
- */
- public final function getParserInstance () {
- return $this->parserInstance;
- }
-
- /**
- * Setter for DatabaseWrapper instance
- *
- * @param $wrapperInstance An instance of an DatabaseWrapper
- * @return void
- */
- public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) {
- $this->wrapperInstance = $wrapperInstance;
- }
-
- /**
- * Getter for DatabaseWrapper instance
- *
- * @return $wrapperInstance An instance of an DatabaseWrapper
- */
- public final function getWrapperInstance () {
- return $this->wrapperInstance;
- }
-
- /**
- * Setter for socket resource
- *
- * @param $socketResource A valid socket resource
- * @return void
- */
- public final function setSocketResource ($socketResource) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
- $this->socketResource = $socketResource;
- }
-
- /**
- * Getter for socket resource
- *
- * @return $socketResource A valid socket resource
- */
- public final function getSocketResource () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
- return $this->socketResource;
- }
-
- /**
- * Setter for regular expression
- *
- * @param $regularExpression A valid regular expression
- * @return void
- */
- public final function setRegularExpression ($regularExpression) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
- $this->regularExpression = $regularExpression;
- }
-
- /**
- * Getter for regular expression
- *
- * @return $regularExpression A valid regular expression
- */
- public final function getRegularExpression () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression);
- return $this->regularExpression;
- }
-
- /**
- * Setter for helper instance
- *
- * @param $helperInstance An instance of a helper class
- * @return void
- */
- protected final function setHelperInstance (Helper $helperInstance) {
- $this->helperInstance = $helperInstance;
- }
-
- /**
- * Getter for helper instance
- *
- * @return $helperInstance An instance of a helper class
- */
- public final function getHelperInstance () {
- return $this->helperInstance;
- }
-
- /**
- * Setter for a Source instance
- *
- * @param $sourceInstance An instance of a Source class
- * @return void
- */
- protected final function setSourceInstance (Source $sourceInstance) {
- $this->sourceInstance = $sourceInstance;
- }
-
- /**
- * Getter for a Source instance
- *
- * @return $sourceInstance An instance of a Source class
- */
- protected final function getSourceInstance () {
- return $this->sourceInstance;
- }
-
- /**
- * Setter for a UrlSource instance
- *
- * @param $sourceInstance An instance of a UrlSource class
- * @return void
- */
- protected final function setUrlSourceInstance (UrlSource $urlSourceInstance) {
- $this->urlSourceInstance = $urlSourceInstance;
- }
-
- /**
- * Getter for a UrlSource instance
- *
- * @return $urlSourceInstance An instance of a UrlSource class
- */
- protected final function getUrlSourceInstance () {
- return $this->urlSourceInstance;
- }
-
- /**
- * Getter for a InputStream instance
- *
- * @param $inputStreamInstance The InputStream instance
- */
- protected final function getInputStreamInstance () {
- return $this->inputStreamInstance;
- }
-
- /**
- * Setter for a InputStream instance
- *
- * @param $inputStreamInstance The InputStream instance
- * @return void
- */
- protected final function setInputStreamInstance (InputStream $inputStreamInstance) {
- $this->inputStreamInstance = $inputStreamInstance;
- }
-
- /**
- * Getter for a OutputStream instance
- *
- * @param $outputStreamInstance The OutputStream instance
- */
- protected final function getOutputStreamInstance () {
- return $this->outputStreamInstance;
- }
-
- /**
- * Setter for a OutputStream instance
- *
- * @param $outputStreamInstance The OutputStream instance
- * @return void
- */
- protected final function setOutputStreamInstance (OutputStream $outputStreamInstance) {
- $this->outputStreamInstance = $outputStreamInstance;
- }
-
- /**
- * Setter for handler instance
- *
- * @param $handlerInstance An instance of a Handleable class
- * @return void
- */
- protected final function setHandlerInstance (Handleable $handlerInstance) {
- $this->handlerInstance = $handlerInstance;
- }
-
- /**
- * Getter for handler instance
- *
- * @return $handlerInstance A Handleable instance
- */
- protected final function getHandlerInstance () {
- return $this->handlerInstance;
- }
-
- /**
- * Setter for visitor instance
- *
- * @param $visitorInstance A Visitor instance
- * @return void
- */
- protected final function setVisitorInstance (Visitor $visitorInstance) {
- $this->visitorInstance = $visitorInstance;
- }
-
- /**
- * Getter for visitor instance
- *
- * @return $visitorInstance A Visitor instance
- */
- protected final function getVisitorInstance () {
- return $this->visitorInstance;
- }
-
- /**
- * Setter for raw package Data
- *
- * @param $packageData Raw package Data
- * @return void
- */
- public final function setPackageData (array $packageData) {
- $this->packageData = $packageData;
- }
-
- /**
- * Getter for raw package Data
- *
- * @return $packageData Raw package Data
- */
- public function getPackageData () {
- return $this->packageData;
- }
-
-
- /**
- * Setter for Iterator instance
- *
- * @param $iteratorInstance An instance of an Iterator
- * @return void
- */
- protected final function setIteratorInstance (Iterator $iteratorInstance) {
- $this->iteratorInstance = $iteratorInstance;
- }
-
- /**
- * Getter for Iterator instance
- *
- * @return $iteratorInstance An instance of an Iterator
- */
- public final function getIteratorInstance () {
- return $this->iteratorInstance;
- }
-
- /**
- * Setter for FilePointer instance
- *
- * @param $pointerInstance An instance of an FilePointer class
- * @return void
- */
- protected final function setPointerInstance (FilePointer $pointerInstance) {
- $this->pointerInstance = $pointerInstance;
- }
-
- /**
- * Getter for FilePointer instance
- *
- * @return $pointerInstance An instance of an FilePointer class
- */
- public final function getPointerInstance () {
- return $this->pointerInstance;
- }
-
- /**
- * Unsets pointer instance which triggers a call of __destruct() if the
- * instance is still there. This is surely not fatal on already "closed"
- * file pointer instances.
- *
- * I don't want to mess around with above setter by giving it a default
- * value NULL as setter should always explicitly only set (existing) object
- * instances and NULL is NULL.
- *
- * @return void
- */
- protected final function unsetPointerInstance () {
- // Simply it to NULL
- $this->pointerInstance = NULL;
- }
-
- /**
- * Setter for Indexable instance
- *
- * @param $indexInstance An instance of an Indexable class
- * @return void
- */
- protected final function setIndexInstance (Indexable $indexInstance) {
- $this->indexInstance = $indexInstance;
- }
-
- /**
- * Getter for Indexable instance
- *
- * @return $indexInstance An instance of an Indexable class
- */
- public final function getIndexInstance () {
- return $this->indexInstance;
- }
-
- /**
- * Setter for Block instance
- *
- * @param $blockInstance An instance of an Block class
- * @return void
- */
- protected final function setBlockInstance (Block $blockInstance) {
- $this->blockInstance = $blockInstance;
- }
-
- /**
- * Getter for Block instance
- *
- * @return $blockInstance An instance of an Block class
- */
- public final function getBlockInstance () {
- return $this->blockInstance;
- }
-
- /**
- * Setter for Minable instance
- *
- * @param $minableInstance A Minable instance
- * @return void
- */
- protected final function setMinableInstance (Minable $minableInstance) {
- $this->minableInstance = $minableInstance;
- }
-
- /**
- * Getter for minable instance
- *
- * @return $minableInstance A Minable instance
- */
- protected final function getMinableInstance () {
- return $this->minableInstance;
- }
-
- /**
- * Setter for FrameworkDirectory instance
- *
- * @param $directoryInstance A FrameworkDirectory instance
- * @return void
- */
- protected final function setDirectoryInstance (FrameworkDirectory $directoryInstance) {
- $this->directoryInstance = $directoryInstance;
- }
-
- /**
- * Getter for FrameworkDirectory instance
- *
- * @return $directoryInstance A FrameworkDirectory instance
- */
- protected final function getDirectoryInstance () {
- return $this->directoryInstance;
- }
-
- /**
- * Getter for communicator instance
- *
- * @return $communicatorInstance An instance of a Communicator class
- */
- public final function getCommunicatorInstance () {
- return $this->communicatorInstance;
- }
-
- /**
- * Setter for communicator instance
- *
- * @param $communicatorInstance An instance of a Communicator class
- * @return void
- */
- protected final function setCommunicatorInstance (Communicator $communicatorInstance) {
- $this->communicatorInstance = $communicatorInstance;
- }
-
- /**
- * Setter for state instance
- *
- * @param $stateInstance A Stateable instance
- * @return void
- */
- public final function setStateInstance (Stateable $stateInstance) {
- $this->stateInstance = $stateInstance;
- }
-
- /**
- * Getter for state instance
- *
- * @return $stateInstance A Stateable instance
- */
- public final function getStateInstance () {
- return $this->stateInstance;
- }
-
- /**
- * Setter for output instance
- *
- * @param $outputInstance The debug output instance
- * @return void
- */
- public final function setOutputInstance (OutputStreamer $outputInstance) {
- $this->outputInstance = $outputInstance;
- }
-
- /**
- * Getter for output instance
- *
- * @return $outputInstance The debug output instance
- */
- public final function getOutputInstance () {
- 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
- *
- * @param $commandName Last validated command name
- * @return void
- */
- protected final function setCommandName ($commandName) {
- $this->commandName = $commandName;
- }
-
- /**
- * Getter for command name
- *
- * @return $commandName Last validated command name
- */
- protected final function getCommandName () {
- return $this->commandName;
- }
-
- /**
- * Setter for controller name
- *
- * @param $controllerName Last validated controller name
- * @return void
- */
- protected final function setControllerName ($controllerName) {
- $this->controllerName = $controllerName;
- }
-
- /**
- * Getter for controller name
- *
- * @return $controllerName Last validated controller name
- */
- protected final function getControllerName () {
- return $this->controllerName;
- }
-
- /**
- * Checks whether an object equals this object. You should overwrite this
- * method to implement own equality checks
- *
- * @param $objectInstance An instance of a FrameworkInterface object
- * @return $equals Whether both objects equals
- */
- public function equals (FrameworkInterface $objectInstance) {
- // Now test it
- $equals = ((
- $this->__toString() == $objectInstance->__toString()
- ) && (
- $this->hashCode() == $objectInstance->hashCode()
- ));
-
- // Return the result
- return $equals;
- }
-
- /**
- * Generates a generic hash code of this class. You should really overwrite
- * this method with your own hash code generator code. But keep KISS in mind.
- *
- * @return $hashCode A generic hash code respresenting this whole class
- */
- public function hashCode () {
- // Simple hash code
- return crc32($this->__toString());
- }
-
- /**
- * Formats computer generated price values into human-understandable formats
- * with thousand and decimal separators.
- *
- * @param $value The in computer format value for a price
- * @param $currency The currency symbol (use HTML-valid characters!)
- * @param $decNum Number of decimals after commata
- * @return $price The for the current language formated price string
- * @throws MissingDecimalsThousandsSeparatorException If decimals or
- * thousands separator
- * is missing
- */
- public function formatCurrency ($value, $currency = '€', $decNum = 2) {
- // Are all required attriutes set?
- if ((!isset($this->decimals)) || (!isset($this->thousands))) {
- // Throw an exception
- throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
- } // END - if
-
- // Cast the number
- $value = (float) $value;
-
- // Reformat the US number
- $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency;
-
- // Return as string...
- return $price;
- }
-
- /**
- * Appends a trailing slash to a string
- *
- * @param $str A string (maybe) without trailing slash
- * @return $str A string with an auto-appended trailing slash
- */
- public final function addMissingTrailingSlash ($str) {
- // Is there a trailing slash?
- if (substr($str, -1, 1) != '/') {
- $str .= '/';
- } // END - if
-
- // Return string with trailing slash
- return $str;
- }
-
- /**
- * Prepare the template engine (HtmlTemplateEngine by default) for a given
- * application helper instance (ApplicationHelper by default).
- *
- * @param $applicationInstance An application helper instance or
- * null if we shall use the default
- * @return $templateInstance The template engine instance
- * @throws NullPointerException If the discovered application
- * instance is still null
- */
- protected function prepareTemplateInstance (ManageableApplication $applicationInstance = NULL) {
- // Is the application instance set?
- if (is_null($applicationInstance)) {
- // Get the current instance
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- // Still null?
- if (is_null($applicationInstance)) {
- // Thrown an exception
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
- } // END - if
-
- // Initialize the template engine
- $templateInstance = ObjectFactory::createObjectByConfiguredName('html_template_class');
-
- // Return the prepared instance
- return $templateInstance;
- }
-
- /**
- * Debugs this instance by putting out it's full content
- *
- * @param $message Optional message to show in debug output
- * @return void
- */
- public final function debugInstance ($message = '') {
- // Restore the error handler to avoid trouble with missing array elements or undeclared variables
- restore_error_handler();
+ public final function debugInstance (string $message = '') {
+ // Restore the error handler to avoid trouble with missing array elements or undeclared variables
+ restore_error_handler();
// Init content
$content = '';
@@ -1737,7 +515,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
$content = sprintf('
Message: %s
' . PHP_EOL, $message);
- } // END - if
+ }
// Generate the output
$content .= sprintf('%s
',
@@ -1749,7 +527,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
);
// Output it
- ApplicationEntryPoint::app_exit(sprintf('