]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/factories/node/class_NodeObjectFactory.php
Updated 'core' + renamed 'main' -> 'classes'.
[hub.git] / application / hub / main / factories / node / class_NodeObjectFactory.php
diff --git a/application/hub/main/factories/node/class_NodeObjectFactory.php b/application/hub/main/factories/node/class_NodeObjectFactory.php
deleted file mode 100644 (file)
index 39baf65..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-/**
- * A factory class for nodes
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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 NodeObjectFactory extends ObjectFactory {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Returns a singleton (registry-based) NodeHelper instance
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      $nodeInstance           An instance of a NodeHelper class
-        * @throws      FactoryRequiredParameterException       If not all parameters are set and no instance 'node' is set.
-        */
-       public static final function createNodeInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
-               // Get new factory instance
-               $factoryInstance = new NodeObjectFactory();
-
-               // If there is no handler?
-               if (Registry::getRegistry()->instanceExists('node')) {
-                       // Get handler from registry
-                       $nodeInstance = Registry::getRegistry()->getInstance('node');
-               } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
-                       // The default node-mode is from our configuration
-                       $nodeMode = $factoryInstance->getConfigInstance()->getConfigEntry('node_default_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' . $factoryInstance->convertToClassName($nodeMode) . 'Node';
-
-                       // Get the node instance
-                       $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
-                       // Get a registry
-                       $applicationInstance = Registry::getRegistry()->getInstance('app');
-
-                       // Set the app instance
-                       $nodeInstance->setApplicationInstance($applicationInstance);
-
-                       // Add node-specific filters
-                       $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
-
-                       // Add it to the registry
-                       Registry::getRegistry()->addInstance('node', $nodeInstance);
-               } else {
-                       // Throw an exception here
-                       throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
-               }
-
-               // Return the instance
-               return $nodeInstance;
-       }
-}
-
-// [EOF]
-?>