]> git.mxchange.org Git - hub.git/commitdiff
Move array initialization into constructor to allow usage of constants
authorRoland Häder <roland@mxchange.org>
Tue, 17 Jul 2012 18:51:02 +0000 (18:51 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 17 Jul 2012 18:51:02 +0000 (18:51 +0000)
application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php

index 4223c8d9c9a24e50b1b1ed339d7ad06304541612..e84eca40822995c8dc3b0aedb073346f7042315b 100644 (file)
@@ -45,22 +45,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         * Sub nodes in the XML tree
         */
        private $subNodes = array(
-               // These nodes don't contain any data
-               'my-data',
-               'your-data',
-               // Data from *this* node
-               'my-external-ip',
-               'my-internal-ip',
-               'my-tcp-port',
-               'my-udp-port',
-               'my-session-id',
-               'my-status',
-               // Data from other node
-               'your-external-ip',
-               'your-internal-ip',
-               'your-session-id',
-               // Answer status (code)
-               'answer-status'
        );
 
        /**
@@ -76,6 +60,26 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Init sub-nodes array
+               $this->subNodes = array(
+                       // These nodes don't contain any data
+                       'my-data',
+                       'your-data',
+                       // Data from *this* node
+                       self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
+                       self::ANNOUNCEMENT_DATA_INTERNAL_IP,
+                       self::ANNOUNCEMENT_DATA_TCP_PORT,
+                       self::ANNOUNCEMENT_DATA_UDP_PORT,
+                       self::ANNOUNCEMENT_DATA_NODE_STATUS,
+                       self::ANNOUNCEMENT_DATA_NODE_STATUS,
+                       // Data from other node
+                       'your-external-ip',
+                       'your-internal-ip',
+                       'your-session-id',
+                       // Answer status (code)
+                       self::ANNOUNCEMENT_DATA_ANSWER_STATUS
+               );
        }
 
        /**
@@ -325,7 +329,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMyExternalIp () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-external-ip');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
        }
 
        /**
@@ -335,7 +339,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMyInternalIp () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-internal-ip');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
        }
 
        /**
@@ -345,7 +349,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMyTcpPort () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-tcp-port');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_TCP_PORT);
        }
 
        /**
@@ -355,7 +359,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMyUdpPort () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-udp-port');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_UDP_PORT);
        }
 
        /**
@@ -365,7 +369,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMySessionId () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-session-id');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
        }
 
        /**
@@ -375,7 +379,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startMyStatus () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'my-status');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
        }
 
        /**
@@ -535,7 +539,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseTemplateEngine implements
         */
        private function startAnswerStatus () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('announcement_answer', 'answer-status');
+               $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_ANSWER_STATUS);
        }
 
        /**