]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/filter/node/class_NodeInitializationFilter.php
Continued with hub:
[hub.git] / application / hub / main / filter / node / class_NodeInitializationFilter.php
index 097e693c77b5ee389705d3530426f1f91ac9007a..bf2e596eba0108f7c45bdffcafaa552824be0b49 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A Initialization filter for nodes
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class NodeInitializationFilter extends BaseFilter implements Filterable {
+class NodeInitializationFilter extends BaseNodeFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -37,7 +37,7 @@ class NodeInitializationFilter extends BaseFilter implements Filterable {
         *
         * @return      $filterInstance         An instance of this filter class
         */
-       public final static function createNodeInitializationFilter () {
+       public static final function createNodeInitializationFilter () {
                // Get a new instance
                $filterInstance = new NodeInitializationFilter();
 
@@ -51,45 +51,21 @@ class NodeInitializationFilter extends BaseFilter implements Filterable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // The default node-mode is from our configuration
-               $nodeMode = $this->getConfigInstance()->getConfigEntry('node_mode');
-
-               // Is the node 'mode' parameter set?
-               if ($requestInstance->isRequestElementSet('mode')) {
-                       // Then use this which overrides the config entry temporarily
-                       $nodeMode = $requestInstance->getRequestElement('mode');
-               } else {
-                       // Set it for easier re-usage
-                       $requestInstance->setRequestElement('mode', $nodeMode);
-               }
-
-               // Now convert the node-mode in a class name
-               $className = 'Hub' . $this->convertToClassName($nodeMode) . 'Node';
-
-               // And try to instance it
+               // Try to instance it by using a factory
                try {
                        // Get an instance
-                       $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
-                       // Get a registry
-                       $appInstance = Registry::getRegistry()->getInstance('app');
-
-                       // Set the app instance
-                       $nodeInstance->setApplicationInstance($appInstance);
-
-                       // Add node-specific filters
-                       $nodeInstance->addExtraFilters($requestInstance, $responseInstance);
+                       $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance);
                } catch (ClassNotFoundException $e) {
                        // This exception means, the node mode is invalid.
-                       // @TODO Can we rewrite this to app_die() ?
-                       die('Node mode ' . $nodeMode . ' is invalid.' . "\n");
+                       // @TODO Can we rewrite this to app_exit() ?
+                       $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']:  node mode ' . $nodeMode . ' is invalid.');
                }
 
                // Set the node instance in registry
                Registry::getRegistry()->addInstance('node', $nodeInstance);
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Node ' . $nodeMode . ' has been added to registry.');
        }
 }