From: Roland Häder Date: Tue, 17 Jul 2012 18:51:02 +0000 (+0000) Subject: Move array initialization into constructor to allow usage of constants X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a946fe943023c03cda227bd7510ac5258f7c155f;p=hub.git Move array initialization into constructor to allow usage of constants --- diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index 4223c8d9c..e84eca408 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -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); } /**