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\CompileableTemplate;
14 * A RequestNodeListAnswer template engine class for XML templates
16 * @author Roland Haeder <webmaster@shipsimu.org>
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()
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.
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.
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/>.
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';
42 * Protected constructor
46 protected function __construct () {
47 // Call parent constructor
48 parent::__construct(__CLASS__);
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)
60 * Creates an instance of the class TemplateEngine and prepares it for usage
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
70 public static final function createXmlRequestNodeListAnswerTemplateEngine () {
72 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
75 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
77 // Get a template instance for list entries (as they are dynamic)
78 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
81 $templateInstance->setTemplateInstance($entriesInstance);
83 // Return the prepared instance
84 return $templateInstance;
90 * @param $resource XML parser resource (currently ignored)
91 * @param $characters Characters to handle
93 * @todo Find something useful with this!
95 public function characterHandler ($resource, $characters) {
96 // Trim all spaces away
97 $characters = trim($characters);
99 // Is this string empty?
100 if (empty($characters)) {
101 // Then skip it silently
106 * Assign the found characters to variable and use the last entry from
109 parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters);
113 * Getter for cache file (FQFN)
115 * @return $fqfn Full-qualified file name of the menu cache
117 public function getRequestNodeListAnswerCacheFqfn () {
118 $this->partialStub('Please implement this method.');
122 * Starts the 'request-node-list-answer'
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');
132 * Starts the session-id
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);
142 * Starts the node-list
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);
152 * Finishes the node-list
156 protected function finishNodeList () {
157 // Pop the last entry
158 $this->getStackInstance()->popNamed('node_request_node_list_answer');
162 * Finishes the session-id
166 protected function finishSessionId () {
167 // Pop the last entry
168 $this->getStackInstance()->popNamed('node_request_node_list_answer');
172 * Finishes the 'request-node-list-answer'
176 protected function finishRequestNodeListAnswer () {
177 // Pop the last entry
178 $this->getStackInstance()->popNamed('node_request_node_list_answer');