]> git.mxchange.org Git - hub.git/blob
f954b517d65a4d6dc9c69f9ffa5582d1bd6bae5f
[hub.git] /
1 <?php
2 // Own namespace
3 namespace Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Request\NodeList;
4
5 // Import application-specific stuff
6 use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
7
8 // Import framework stuff
9 use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory;
10 use Org\Mxchange\CoreFramework\Registry\Registerable;
11 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
12
13 /**
14  * A RequestNodeListAnswer template engine class for XML templates
15  *
16  * @author              Roland Haeder <webmaster@shipsimu.org>
17  * @version             0.0.0
18  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
19  * @license             GNU GPL 3.0 or any newer version
20  * @link                http://www.shipsimu.org
21  * @todo                This template engine does not make use of setTemplateType()
22  *
23  * This program is free software: you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation, either version 3 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program. If not, see <http://www.gnu.org/licenses/>.
35  */
36 class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
37         // Constants for array elements
38         const REQUEST_DATA_SESSION_ID    = 'session-id';
39         const REQUEST_DATA_NODE_LIST     = 'node-list';
40
41         /**
42          * Protected constructor
43          *
44          * @return      void
45          */
46         protected function __construct () {
47                 // Call parent constructor
48                 parent::__construct(__CLASS__);
49
50                 // Init sub-nodes array
51                 $this->setSubNodes(array(
52                         self::REQUEST_DATA_SESSION_ID,
53                         self::REQUEST_DATA_NODE_LIST,
54                         // Answer status (generic field)
55                         self::ANSWER_STATUS,
56                 ));
57         }
58
59         /**
60          * Creates an instance of the class TemplateEngine and prepares it for usage
61          *
62          * @return      $templateInstance               An instance of TemplateEngine
63          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
64          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
65          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
66          *                                                                                      directory or not found
67          * @throws      BasePathReadProtectedException  If $templateBasePath is
68          *                                                                                      read-protected
69          */
70         public static final function createXmlRequestNodeListAnswerTemplateEngine () {
71                 // Get a new instance
72                 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
73
74                 // Init instance
75                 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
76
77                 // Get a template instance for list entries (as they are dynamic)
78                 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
79
80                 // Set it here
81                 $templateInstance->setTemplateInstance($entriesInstance);
82
83                 // Return the prepared instance
84                 return $templateInstance;
85         }
86
87         /**
88          * Currently not used
89          *
90          * @param       $resource               XML parser resource (currently ignored)
91          * @param       $characters             Characters to handle
92          * @return      void
93          * @todo        Find something useful with this!
94          */
95         public function characterHandler ($resource, $characters) {
96                 // Trim all spaces away
97                 $characters = trim($characters);
98
99                 // Is this string empty?
100                 if (empty($characters)) {
101                         // Then skip it silently
102                         return;
103                 } // END - if
104
105                 /*
106                  * Assign the found characters to variable and use the last entry from
107                  * stack as the name.
108                  */
109                 parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters);
110         }
111
112         /**
113          * Getter for cache file (FQFN)
114          *
115          * @return      $fqfn   Full-qualified file name of the menu cache
116          */
117         public function getRequestNodeListAnswerCacheFqfn () {
118                 $this->partialStub('Please implement this method.');
119         }
120
121         /**
122          * Starts the 'request-node-list-answer'
123          *
124          * @return      void
125          */
126         protected function startRequestNodeListAnswer () {
127                 // Push the node name on the stacker
128                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer');
129         }
130
131         /**
132          * Starts the session-id
133          *
134          * @return      void
135          */
136         protected function startSessionId () {
137                 // Push the node name on the stacker
138                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID);
139         }
140
141         /**
142          * Starts the node-list
143          *
144          * @return      void
145          */
146         protected function startNodeList () {
147                 // Push the node name on the stacker
148                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST);
149         }
150
151         /**
152          * Finishes the node-list
153          *
154          * @return      void
155          */
156         protected function finishNodeList () {
157                 // Pop the last entry
158                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
159         }
160
161         /**
162          * Finishes the session-id
163          *
164          * @return      void
165          */
166         protected function finishSessionId () {
167                 // Pop the last entry
168                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
169         }
170
171         /**
172          * Finishes the 'request-node-list-answer'
173          *
174          * @return      void
175          */
176         protected function finishRequestNodeListAnswer () {
177                 // Pop the last entry
178                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
179         }
180 }
181
182 // [EOF]
183 ?>