X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=7087af8d28124c6451e032f1288198a63f4a73f9;hp=94c13b750e3af3ccf586a58f070cb36472aaaa4e;hb=62177049b25b2662ded30789c712f9777fa6d01b;hpb=de2d894308a066a7315746ef5067806b9d99eb2c diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 94c13b75..7087af8d 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -144,7 +144,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { private $helperInstance = NULL; /** - * An instance of a Sourceable class + * An instance of a Source class */ private $sourceInstance = NULL; @@ -1142,19 +1142,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Setter for a Sourceable instance + * Setter for a Source instance * - * @param $sourceInstance An instance of a Sourceable class + * @param $sourceInstance An instance of a Source class * @return void */ - protected final function setSourceInstance (Sourceable $sourceInstance) { + protected final function setSourceInstance (Source $sourceInstance) { $this->sourceInstance = $sourceInstance; } /** - * Getter for a Sourceable instance + * Getter for a Source instance * - * @return $sourceInstance An instance of a Sourceable class + * @return $sourceInstance An instance of a Source class */ protected final function getSourceInstance () { return $this->sourceInstance; @@ -1948,7 +1948,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function getDatabaseEntry () { // Is there an instance? - if (is_null($this->getResultInstance())) { + if (!$this->getResultInstance() instanceof SearchableResult) { // Throw an exception here throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } // END - if @@ -1997,12 +1997,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':
'.print_r($fieldArray, TRUE).'
'); // Convert dashes to underscore - $fieldName = $this->convertDashesToUnderscores($fieldName); + $fieldName2 = $this->convertDashesToUnderscores($fieldName); // Does the field exist? - if (isset($fieldArray[$fieldName])) { + if ($this->isFieldSet($fieldName)) { // Get it - $fieldValue = $fieldArray[$fieldName]; + $fieldValue = $fieldArray[$fieldName2]; } elseif (defined('DEVELOPER')) { // Missing field entry, may require debugging self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, TRUE) . '
,fieldName=' . $fieldName . ' not found!'); @@ -2015,6 +2015,37 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { return $fieldValue; } + /** + * Checks if given field is set + * + * @param $fieldName Field name to check + * @return $isSet Whether the given field name is set + * @throws NullPointerException If the result instance is null + */ + public function isFieldSet ($fieldName) { + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is this instance null? + if (is_null($resultInstance)) { + // Then the user instance is no longer valid (expired cookies?) + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get current array + $fieldArray = $resultInstance->current(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, TRUE).'
'); + + // Convert dashes to underscore + $fieldName = $this->convertDashesToUnderscores($fieldName); + + // Determine it + $isSet = isset($fieldArray[$fieldName]); + + // Return result + return $isSet; + } + /** * Flushs all pending updates to the database layer *