]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php
While self-connect is running, it might be already announced which is fine
[hub.git] / application / hub / main / helper / hub / connection / class_HubSelfConnectHelper.php
index 33289725a3ea9c5d5710faa0b2f09e83c87d48d6..1f210fba22f5d2ff26e7189ba5e34929d6f3bcb8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  * @todo               Find an interface for hub helper
@@ -44,16 +44,12 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
        /**
         * Creates the helper class
         *
-        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      $helperInstance         A prepared instance of this helper
         */
-       public final static function createHubSelfConnectHelper (NodeHelper $nodeInstance) {
+       public static final function createHubSelfConnectHelper () {
                // Get new instance
                $helperInstance = new HubSelfConnectHelper();
 
-               // Set the node instance
-               $helperInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $helperInstance;
        }
@@ -67,20 +63,8 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
                // Debug message
                $this->debugOutput('HELPER: Attempting self-connect...');
 
-               // Get the application instance
-               $appInstance = Registry::getRegistry()->getInstance('app');
-
                // Get a XML template instance
-               $templateInstance = ObjectFactory::createObjectByConfiguredName('self_connect_template_class', array($appInstance));
-
-               // Disable language support
-               $templateInstance->enableLanguageSupport(false);
-
-               /*
-                * Enable compacting/rewriting of the  XML to save bandwidth from XML
-                * comments. This is expensive and should be avoided in general.
-                */
-               $templateInstance->enableXmlCompacting();
+               $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class');
 
                // Set it for later use
                $this->setTemplateInstance($templateInstance);
@@ -95,11 +79,12 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
        /**
         * Do the self-connect attempt by delivering a package to ourselfs
         *
+        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      void
         */
-       public function sendPackage () {
+       public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnounced();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();