Now with getter
[core.git] / inc / classes / main / helper / class_BaseHelper.php
index 89a3babe5e27c6d7a6b6934053f11938499bf85d..da4f6b12b3f0fffe558ac1d0ab99c5c4539b341b 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007 - 2009 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -76,10 +76,6 @@ class BaseHelper extends BaseFrameworkSystem {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
@@ -194,8 +190,13 @@ class BaseHelper extends BaseFrameworkSystem {
         * @throws      NullPointerException    If recovery of requested value instance failed
         */
        public function prefetchValueInstance ($registryKey, $extraKey = null) {
-               // Get the required instance
-               $this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
+               try {
+                       // Get the required instance
+                       $this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
+               } catch (NullPointerException $e) {
+                       // Not set in registry
+                       // @TODO Try to log it here
+               }
 
                // Is the value instance valid?
                if (is_null($this->valueInstance)) {
@@ -208,10 +209,9 @@ class BaseHelper extends BaseFrameworkSystem {
                                $extraInstance = Registry::getRegistry()->getInstance($extraKey);
                        } // END - if
 
-                       // Get the requested instance
                        try {
+                               // Get the requested instance
                                $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($extraInstance));
-
                        } catch (FrameworkException $e) {
                                // Okay, nothing found so throw a null pointer exception here
                                throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
@@ -440,8 +440,13 @@ class BaseHelper extends BaseFrameworkSystem {
         * @return      $fieldValue             Value from field
         */
        public function getValueField ($fieldName) {
+               // Construct the eval() command
+               $eval = sprintf("\$fieldValue = \$this->getValueInstance()->getField('%s');",
+                       $fieldName
+               );
+
                // Get the field value
-               $fieldValue = call_user_func_array(array($this->valueInstance, 'getField'), array($fieldName));
+               eval($eval);
 
                // Return it
                return $fieldValue;