3 namespace Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Request\NodeList;
5 // Import application-specific stuff
6 use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
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\Xml\CompileableXmlTemplate;
12 use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
15 * A RequestNodeListAnswer template engine class for XML templates
17 * @author Roland Haeder <webmaster@shipsimu.org>
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Hub Developer Team
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.shipsimu.org
22 * @todo This template engine does not make use of setTemplateType()
24 * This program is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program. If not, see <http://www.gnu.org/licenses/>.
37 class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableXmlTemplate, Registerable {
39 use CompileableTemplateTrait;
41 // Constants for array elements
42 const REQUEST_DATA_SESSION_ID = 'session-id';
43 const REQUEST_DATA_NODE_LIST = 'node-list';
46 * Protected constructor
50 private function __construct () {
51 // Call parent constructor
52 parent::__construct(__CLASS__);
54 // Init sub-nodes array
55 $this->setSubNodes(array(
56 self::REQUEST_DATA_SESSION_ID,
57 self::REQUEST_DATA_NODE_LIST,
58 // Answer status (generic field)
64 * Creates an instance of the class TemplateEngine and prepares it for usage
66 * @return $templateInstance An instance of TemplateEngine
67 * @throws BasePathIsEmptyException If the provided $templateBasePath is empty
68 * @throws InvalidBasePathStringException If $templateBasePath is no string
69 * @throws BasePathIsNoDirectoryException If $templateBasePath is no
70 * directory or not found
71 * @throws BasePathReadProtectedException If $templateBasePath is
74 public static final function createXmlRequestNodeListAnswerTemplateEngine () {
76 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
79 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
81 // Get a template instance for list entries (as they are dynamic)
82 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
85 $templateInstance->setTemplateInstance($entriesInstance);
87 // Return the prepared instance
88 return $templateInstance;
94 * @param $resource XML parser resource (currently ignored)
95 * @param $characters Characters to handle
97 * @todo Find something useful with this!
99 public function characterHandler ($resource, string $characters) {
100 // Trim all spaces away
101 $characters = trim($characters);
103 // Is this string empty?
104 if (empty($characters)) {
105 // Then skip it silently
110 * Assign the found characters to variable and use the last entry from
113 parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters);
117 * Getter for cache file (FQFN)
119 * @return $fqfn Full-qualified file name of the menu cache
121 public function getRequestNodeListAnswerCacheFqfn () {
122 $this->partialStub('Please implement this method.');
126 * Starts the 'request-node-list-answer'
130 protected function startRequestNodeListAnswer () {
131 // Push the node name on the stacker
132 $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer');
136 * Starts the session-id
140 protected function startSessionId () {
141 // Push the node name on the stacker
142 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID);
146 * Starts the node-list
150 protected function startNodeList () {
151 // Push the node name on the stacker
152 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST);
156 * Finishes the node-list
160 protected function finishNodeList () {
161 // Pop the last entry
162 $this->getStackInstance()->popNamed('node_request_node_list_answer');
166 * Finishes the session-id
170 protected function finishSessionId () {
171 // Pop the last entry
172 $this->getStackInstance()->popNamed('node_request_node_list_answer');
176 * Finishes the 'request-node-list-answer'
180 protected function finishRequestNodeListAnswer () {
181 // Pop the last entry
182 $this->getStackInstance()->popNamed('node_request_node_list_answer');