From b5b759973a983fd01d5d47a681bbc947ad8b2af9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 17 Mar 2014 23:05:53 +0100 Subject: [PATCH] Had to move more code into factory. Signed-off-by: Roland Haeder --- .../factories/node/class_NodeObjectFactory.php | 15 +++++++++++++++ .../node/class_NodeInitializationFilter.php | 18 +----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/application/hub/main/factories/node/class_NodeObjectFactory.php b/application/hub/main/factories/node/class_NodeObjectFactory.php index 79af60dd2..2a6d54f2e 100644 --- a/application/hub/main/factories/node/class_NodeObjectFactory.php +++ b/application/hub/main/factories/node/class_NodeObjectFactory.php @@ -46,6 +46,21 @@ class NodeObjectFactory extends ObjectFactory { // Get handler from registry $nodeInstance = NodeObjectFactory::createNodeInstance(); } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) { + // The default node-mode is from our configuration + $nodeMode = $this->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' . $this->convertToClassName($nodeMode) . 'Node'; + // Get the node instance $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); diff --git a/application/hub/main/filter/node/class_NodeInitializationFilter.php b/application/hub/main/filter/node/class_NodeInitializationFilter.php index 3070e8547..4064df324 100644 --- a/application/hub/main/filter/node/class_NodeInitializationFilter.php +++ b/application/hub/main/filter/node/class_NodeInitializationFilter.php @@ -53,23 +53,7 @@ class NodeInitializationFilter extends BaseNodeFilter implements Filterable { * @return void */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // The default node-mode is from our configuration - $nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode'); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Got default node mode ' . $nodeMode . ' from configuration.'); - - // 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 = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); -- 2.39.5