X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=abcefc8c35f6b2aaed66eaa6e7fa31ed0e3c14c1;hp=8147d5348812038946262bbce89a539280b6b55f;hb=0a638eea103f0f2b6c48374cb8d01e68893f5a65;hpb=fdc6a02b5e6c2155cda61fcc345c7583b734ab85 diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 8147d534..abcefc8c 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -173,6 +173,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $wrapperInstance = NULL; + /** + * An instance of a file I/O pointer class (not handler) + */ + private $pointerInstance = NULL; + /** * Thousands separator */ @@ -249,6 +254,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { 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; @@ -259,7 +265,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_ASSERTION_FAILED = 0x037; const EXCEPTION_FILE_CANNOT_BE_READ = 0x038; const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039; - const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x040; + const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03a; /** * Hexadecimal->Decimal translation array @@ -355,6 +361,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } else { // Do not call this twice trigger_error(__METHOD__ . ': Called twice.'); + exit; } } @@ -1216,6 +1223,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $this->iteratorInstance; } + /** + * Setter for InputOutputPointer instance + * + * @param $pointerInstance An instance of an InputOutputPointer + * @return void + */ + protected final function setPointerInstance (InputOutputPointer $pointerInstance) { + $this->pointerInstance = $pointerInstance; + } + + /** + * Getter for InputOutputPointer instance + * + * @return $pointerInstance An instance of an InputOutputPointer + */ + public final function getPointerInstance () { + return $this->pointerInstance; + } + /** * Checks whether an object equals this object. You should overwrite this * method to implement own equality checks @@ -1410,6 +1436,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } else { // Trigger an error trigger_error($stubMessage); + exit; } } @@ -1444,20 +1471,29 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $debugInstance An instance of a debugger class */ public final static function createDebugInstance ($className) { - // Init debug instance - $debugInstance = NULL; + // Is the instance set? + if (!Registry::getRegistry()->instanceExists('debug')) { + // Init debug instance + $debugInstance = NULL; + + // Try it + try { + // Get a debugger instance + $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class')); + } catch (NullPointerException $e) { + // Didn't work, no instance there + exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); + } - // Try it - try { - // Get a debugger instance - $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class')); - } catch (NullPointerException $e) { - // Didn't work, no instance there - exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); - } + // Empty string should be ignored and used for testing the middleware + DebugMiddleware::getSelfInstance()->output(''); - // 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); + } else { + // Get instance from registry + $debugInstance = Registry::getRegistry()->getDebugInstance(); + } // Return it return $debugInstance; @@ -1775,6 +1811,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } else { // Trigger an error trigger_error($message . "
\n"); + exit; } } else { // @TODO Finish this part! @@ -2198,6 +2235,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { // No, then abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; } // END - if // Debug message @@ -2304,6 +2342,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.'); + exit; } // END - if // Initialize it @@ -2327,6 +2366,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.'); + exit; } // END - if // Initialize it @@ -2351,6 +2391,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { // Already initialized trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.'); + exit; } // END - if // Initialize it @@ -2430,6 +2471,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Not found trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); + exit; } // END - if // Then "pop" it @@ -2457,6 +2499,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Not found trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); + exit; } // END - if // Then "shift" it @@ -2482,6 +2525,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!isset($this->genericArray[$keyGroup])) { // Abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.'); + exit; } // END - if // Then count it @@ -2509,6 +2553,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { // Abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; } // END - if // Then count it @@ -2537,9 +2582,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) { // Not valid trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.'); + exit; } // Then count it @@ -2566,6 +2613,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!isset($this->genericArray[$keyGroup])) { // Then abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.'); + exit; } // END - if // Return it @@ -2605,6 +2653,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Then abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.'); + exit; } // END - if // Return it @@ -2646,6 +2695,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { // Then abort here trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.'); + exit; } // END - if // Return it @@ -2688,6 +2738,23 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Return it return $isValid; } + + /** + * Translates boolean TRUE to 'Y' and FALSE to 'N' + * + * @param $boolean Boolean value + * @return $translated Translated boolean value + */ + public static final function translateBooleanToYesNo ($boolean) { + // Make sure it is really boolean + assert(is_bool($boolean)); + + // "Translate" it + $translated = ($boolean === TRUE) ? 'Y' : 'N'; + + // ... and return it + return $translated; + } } // [EOF]