]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
eval() commands replace by improved object factory, user login class stub added
[shipsimu.git] / inc / classes / main / class_BaseFrameworkSystem.php
index f61deb85c47df5f02c5e04f8bc78c8f8004994bc..7fc55e2c15eca048a3671490fdac1b2be611ffd9 100644 (file)
@@ -293,26 +293,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        if (is_null($this->getDebugInstance())) {
                                // Set the debug output system if it is not debug class ;)
                                $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_engine')));
-                       }
+                       } // END - if
 
                        // Initialize web instance
-                       if (is_null($this->getWebOutputInstance())) {
-                               // Generate the eval() command
-                               $eval = sprintf("\$this->setWebOutputInstance(%s::create%s(\"%s\"));",
-                                       $this->getConfigInstance()->readConfig('web_engine'),
-                                       $this->getConfigInstance()->readConfig('web_engine'),
-                                       $this->getConfigInstance()->readConfig('web_content_type')
-                               );
-
-                               // Debug message
-                               if (defined('DEBUG_EVAL')) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                                       $this->__toString(),
-                                       htmlentities($eval)
-                               ));
+                       if ((is_null($this->getWebOutputInstance())) && ($this->__toString() != "ObjectFactory")) {
+                               // Call our object factory
+                               $outputInstance = ObjectFactory::createObjectByConfiguredName('web_engine', array($this->getConfigInstance()->readConfig('web_content_type')));
 
-                               // Run the command
-                               eval($eval);
-                       }
+                               // And set the instance
+                               $this->setWebOutputInstance($outputInstance);
+                       } // END - if
 
                        // Initialize compressor channel
                        if (is_null($this->getCompressorChannel())) {
@@ -321,7 +311,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                        PATH,
                                        $this->getConfigInstance()->readConfig('compressor_base_path')
                                )));
-                       }
+                       } // END - if
 
                        // Initialize database middleware
                        if (is_null($this->getDatabaseInstance())) {
@@ -330,16 +320,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                                if (is_object($db)) {
                                        // Set the database middleware
                                        $this->setDatabaseInstance($db);
-                               }
-                       }
-               }
+                               } // END - if
+                       } // END - if
+               } // END - if
        }
 
        /**
         * Setter for language instance
         *
-        * @param       $configInstance The configuration instance which shall
-        *                                                      be FrameworkConfiguration
+        * @param       $configInstance         The configuration instance which shall
+        *                                                              be FrameworkConfiguration
         * @return      void
         */
        public final function setConfigInstance (FrameworkConfiguration $configInstance) {
@@ -858,36 +848,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                }
 
                // Initialize the template engine
-               $tplEngine = null;
-               $eval = sprintf("\$tplEngine = %s::create%s(
-       \"%s\",
-       \$appInstance->getLanguageInstance(),
-       \$appInstance->getFileIoInstance()
-);",
-                       $this->getConfigInstance()->readConfig('tpl_engine'),
-                       $this->getConfigInstance()->readConfig('tpl_engine'),
-                       $fqfn
-               );
-
-               // Debug message
-               if ((!is_null($this->getDebugInstance())) && (defined('DEBUG_EVAL'))) {
-                       $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command: <pre><em>%s</em></pre><br />\n",
-                               $this->__toString(),
-                               htmlentities($eval)
-                       ));
-               }
-
-               // Run the command
-               eval($eval);
-
-               // Is it a valid instance?
-               if (is_null($tplEngine)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!$tplEngine instanceof CompileableTemplate) {
-                       // Not an object! ;-(
-                       throw new UnsupportedTemplateEngineException($tplEngine, self::EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED);
-               }
+               $tplEngine = ObjectFactory::createObjectByConfiguredName('tpl_engine', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance()));
 
                // Return the prepared instance
                return $tplEngine;