From: Roland Häder Date: Wed, 2 Dec 2020 07:33:47 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e6632ba800ce900e338884ca18873681338ed647;p=hub.git Continued: - moved DHT-related template classes to proper sub directories - replaced CompileableTemplate with newly added CompileableXmlTemplate interface as this is closer to what the class is about - updated core framework Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php index 966ef7a0c..06b98f676 100644 --- a/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php @@ -48,13 +48,13 @@ class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterableP parent::__construct(__CLASS__); // Init array - $this->dataXmlNodes = array( + $this->dataXmlNodes = [ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => '', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => '', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => '', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE => '', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '', - ); + ]; } /** diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php index 078a3cc5d..1f89332a9 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php @@ -53,37 +53,37 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements $this->setHandlerName('message_announcement_answer'); // Init message data array - $this->messageDataElements = array( + $this->messageDataElements = [ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, BaseXmlAnswerTemplateEngine::ANSWER_STATUS, - ); + ]; // Init message-data->configuration translation array - $this->messageToConfig = array( + $this->messageToConfig = [ /* @TODO Why commented out? XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' */ - ); + ]; // Init config-copy array - $this->configCopy = array( + $this->configCopy = [ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', - ); + ]; // Init array - $this->searchData = array( + $this->searchData = [ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - ); + ]; } /** diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index f4b55509e..97373cff7 100644 --- a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -54,28 +54,28 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl $this->setHandlerName('message_dht_bootstrap'); // Init message data array - $this->messageDataElements = array( + $this->messageDataElements = [ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE, XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, - ); + ]; // Init message-data->configuration translation array - $this->messageToConfig = array( + $this->messageToConfig = [ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' - ); + ]; // Init config-copy array - $this->configCopy = array( + $this->configCopy = [ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', - ); + ]; // Init array $this->searchData = array( diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php index a6fc984f6..d23761a92 100644 --- a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -83,7 +83,7 @@ abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableP * @param $unl UNL to test * @return $ifMatches Whether the found UNL matches own addresss */ - public function isOwnAddress ($unl) { + public function isOwnAddress (string $unl) { // Get own external UNL $externalUnl = HubTools::determineOwnExternalAddress(); diff --git a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php index ac9d605af..76c78d1b9 100644 --- a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php +++ b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php @@ -75,6 +75,7 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { */ public function loadDescriptorXml (Distributable $dhtInstance) { // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-BOOTSTRAP-HELPER: dhtInstance=%s - CALLED!', $dhtInstance->__toString())); self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: Starting with DHT boostrap ...'); // Get a XML template instance @@ -88,6 +89,9 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { // Render the XML content $templateInstance->renderXmlContent(); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: EXIT!'); } /** @@ -97,27 +101,25 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { * @return void */ public function sendPackage (Distributable $dhtInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: CALLED!'); - /* * Sanity check: Is the DHT in the approx. state? 'init' for bootstrap * nodes and 'virgin' for all others. */ + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-BOOTSTRAP-HELPER: dhtInstance=%s - CALLED!', $dhtInstance->__toString())); $dhtInstance->getStateInstance()->validateDhtStateIsVirginOrInit(); // Compile the template, this inserts the loaded dht data into the gaps. $this->getTemplateInstance()->compileTemplate(); // Get a singleton network package instance - $packageInstance = NetworkPackageHandlerFactory::createNetworkPackageHandlerInstance(); + $handlerInstance = NetworkPackageHandlerFactory::createNetworkPackageHandlerInstance(); // Next, feed the content in. The network package class is a pipe-through class. //* DEBUG: */ die(__METHOD__ . ':dhtInstance=' . print_r($dhtInstance, TRUE)); - $packageInstance->enqueueRawDataFromTemplate($this); + $handlerInstance->enqueueRawDataFromTemplate($this); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: EXIT!'); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: EXIT!'); } } diff --git a/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php index 272dac68a..5195d786f 100644 --- a/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php @@ -6,8 +6,8 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Announcement; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An Announcement template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Some XML nodes must be available for later data extraction */ @@ -97,7 +97,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com * @param $characters Characters to handle * @return void */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -362,7 +362,5 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com // Pop the last entry $this->getStackInstance()->popNamed('node_announcement'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index 09eb6b1ad..0a1ef4315 100644 --- a/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEng // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An AnnouncementAnswer template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { +class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Some XML nodes must be available for later data extraction */ @@ -105,7 +105,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -410,7 +410,5 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/answer/class_ b/application/hub/classes/template/xml/answer/class_ index 19ad3bb97..6bac5be31 100644 --- a/application/hub/classes/template/xml/answer/class_ +++ b/application/hub/classes/template/xml/answer/class_ @@ -7,7 +7,7 @@ use Org\Mxchange\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEng // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An ??? answer template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { +class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Protected constructor * @@ -114,7 +114,5 @@ class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements // Pop the last entry $this->getStackInstance()->popNamed('!!!'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php index 4d5eea307..a5e6a25ad 100644 --- a/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php @@ -6,8 +6,8 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An generic answer template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -abstract class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +abstract class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Generic 'answer-status' field */ diff --git a/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php index 3d15afdc1..c155bc8da 100644 --- a/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -8,7 +8,7 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEng // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An DhtBootstrapAnswer template engine class for XML templates @@ -33,7 +33,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { +class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Some XML nodes must be available for later data extraction */ @@ -54,7 +54,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im parent::__construct(__CLASS__); // Init sub-nodes array - $this->setSubNodes(array( + $this->setSubNodes([ // These nodes don't contain any data 'my-data', 'your-data', @@ -71,7 +71,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im self::ANSWER_STATUS, // DHT node list self::DHT_BOOTSTRAP_DATA_NODE_LIST, - )); + ]); } /** @@ -104,7 +104,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -389,7 +389,5 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im // Pop the last entry $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php index f954b517d..b8168c28c 100644 --- a/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -8,7 +8,7 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEng // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * A RequestNodeListAnswer template engine class for XML templates @@ -33,7 +33,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { +class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableXmlTemplate, Registerable { // Constants for array elements const REQUEST_DATA_SESSION_ID = 'session-id'; const REQUEST_DATA_NODE_LIST = 'node-list'; @@ -92,7 +92,7 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -177,7 +177,5 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine // Pop the last entry $this->getStackInstance()->popNamed('node_request_node_list_answer'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/class_ b/application/hub/classes/template/xml/class_ index 707cea3ae..adef7c467 100644 --- a/application/hub/classes/template/xml/class_ +++ b/application/hub/classes/template/xml/class_ @@ -7,7 +7,7 @@ use Org\Mxchange\Hub\Template\Engine\Xml\BaseXmlTemplateEngine; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An ??? template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Protected constructor * @@ -114,7 +114,5 @@ class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableT // Pop the last entry $this->getStackInstance()->popNamed('!!!'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php index eaf2ec1b8..e6146ec86 100644 --- a/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php @@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Tag\Tagable; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; /** @@ -33,7 +33,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Data nodes */ @@ -87,7 +87,7 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); diff --git a/application/hub/classes/template/xml/dht/bootstrap/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/xml/dht/bootstrap/class_XmlDhtBootstrapTemplateEngine.php new file mode 100644 index 000000000..d769acd07 --- /dev/null +++ b/application/hub/classes/template/xml/dht/bootstrap/class_XmlDhtBootstrapTemplateEngine.php @@ -0,0 +1,287 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; + const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; + const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; + const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; + const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; + const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes([ + self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, + 'listener', + self::DHT_BOOTSTRAP_DATA_NODE_STATUS, + self::DHT_BOOTSTRAP_DATA_NODE_MODE, + self::DHT_BOOTSTRAP_DATA_SESSION_ID, + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS + ]); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtBootstrapTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, string $characters) { + // Trim all spaces away + //* NOISY-DEBIG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-DHT-BOOTSTRAP-TEMPLATE-ENGINE: resource[%s]=%s,characters(%d)=%s - CALLED!', gettype($resource), $resource, strlen($characters), $characters)); + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + //* NOISY-DEBIG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-DHT-BOOTSTRAP-TEMPLATE-ENGINE: Current node: %s', $this->getStackInstance()->getNamed('dht_bootstrap'))); + parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); + + // Trace message + //* NOISY-DEBIG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-DHT-BOOTSTRAP-TEMPLATE-ENGINE: EXIT!'); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the dht bootstrap + * + * @return void + */ + protected function startDhtBootstrap () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); + } + + /** + * Starts the dht bootstrap data + * + * @return void + */ + protected function startDhtBootstrapData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap data + * + * @return void + */ + protected function finishDhtBootstrapData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap + * + * @return void + */ + protected function finishDhtBootstrap () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + +} diff --git a/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php deleted file mode 100644 index ea51a1f55..000000000 --- a/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php +++ /dev/null @@ -1,284 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; - const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; - const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; - const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; - const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; - const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, - 'listener', - self::DHT_BOOTSTRAP_DATA_NODE_STATUS, - self::DHT_BOOTSTRAP_DATA_NODE_MODE, - self::DHT_BOOTSTRAP_DATA_SESSION_ID, - self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlDhtBootstrapTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtBootstrapTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the dht bootstrap - * - * @return void - */ - protected function startDhtBootstrap () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); - } - - /** - * Starts the dht bootstrap data - * - * @return void - */ - protected function startDhtBootstrapData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap data - * - * @return void - */ - protected function finishDhtBootstrapData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap - * - * @return void - */ - protected function finishDhtBootstrap () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php new file mode 100644 index 000000000..c00113a78 --- /dev/null +++ b/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -0,0 +1,366 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const PUBLISH_DATA_NODE_ID = 'node-id'; + const PUBLISH_DATA_SESSION_ID = 'session-id'; + const PUBLISH_DATA_NODE_STATUS = 'node-status'; + const PUBLISH_DATA_NODE_MODE = 'node-mode'; + const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; + const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; + const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'publish-data', + 'listener', + self::PUBLISH_DATA_NODE_STATUS, + self::PUBLISH_DATA_NODE_MODE, + self::PUBLISH_DATA_PRIVATE_KEY_HASH, + self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, + self::PUBLISH_DATA_NODE_ID, + self::PUBLISH_DATA_SESSION_ID, + self::PUBLISH_DATA_EXTERNAL_ADDRESS, + 'object-type-list', + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtPublishEntryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtPublishEntryTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, string $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the publish + * + * @return void + */ + protected function startPublish () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish'); + } + + /** + * Starts the publish data + * + * @return void + */ + protected function startPublishData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'listener'); + } + + /** + * Starts accepted object types + * + * @return void + */ + protected function startAcceptedObjectTypes () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); + } + + /** + * Starts hash from private key + * + * @return void + */ + protected function startPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes hash from private key + * + * @return void + */ + protected function finishPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes accepted object types + * + * @return void + */ + protected function finishAcceptedObjectTypes () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish data + * + * @return void + */ + protected function finishPublishData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish + * + * @return void + */ + protected function finishPublish () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + +} diff --git a/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php index aff38500b..a79701fac 100644 --- a/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php +++ b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php @@ -6,7 +6,7 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; /** @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Protected constructor * @@ -73,7 +73,7 @@ class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implem * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -115,7 +115,5 @@ class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implem // Pop the last entry $this->getStackInstance()->popNamed('node_request_node_list_entry'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php index 5edc06dbd..8ae96ea15 100644 --- a/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php +++ b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php @@ -8,8 +8,8 @@ use Org\Shipsimu\Hub\Factory\Registry\Object\ObjectTypeRegistryFactory; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An ObjectRegistry template engine class for XML templates @@ -34,7 +34,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { // Constants const OBJECT_TYPE_DATA_NAME = 'object-name'; const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; @@ -100,7 +100,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C * @param $characters Characters to handle * @return void */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: resource[%s]=%s,characters[%s]=%s - CALLED!', gettype($resource), $resource, gettype($characters), $characters)); $characters = trim($characters); diff --git a/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php index 36b805bb2..634a825b7 100644 --- a/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -6,8 +6,8 @@ namespace Org\Shipsimu\Hub\Cruncher\Template\Engine\Xml\TestUnit; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An TestUnit template engine class for XML templates @@ -32,7 +32,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { /** * Protected constructor * @@ -88,7 +88,7 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements * @param $characters Characters to handle * @return void */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -373,7 +373,5 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements // Pop the last entry $this->getStackInstance()->popNamed('cruncher_test_unit'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php deleted file mode 100644 index 4f818bf75..000000000 --- a/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ /dev/null @@ -1,368 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const PUBLISH_DATA_NODE_ID = 'node-id'; - const PUBLISH_DATA_SESSION_ID = 'session-id'; - const PUBLISH_DATA_NODE_STATUS = 'node-status'; - const PUBLISH_DATA_NODE_MODE = 'node-mode'; - const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; - const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; - const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'publish-data', - 'listener', - self::PUBLISH_DATA_NODE_STATUS, - self::PUBLISH_DATA_NODE_MODE, - self::PUBLISH_DATA_PRIVATE_KEY_HASH, - self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, - self::PUBLISH_DATA_NODE_ID, - self::PUBLISH_DATA_SESSION_ID, - self::PUBLISH_DATA_EXTERNAL_ADDRESS, - 'object-type-list', - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlDhtPublishEntryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtPublishEntryTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the publish - * - * @return void - */ - protected function startPublish () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish'); - } - - /** - * Starts the publish data - * - * @return void - */ - protected function startPublishData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'listener'); - } - - /** - * Starts accepted object types - * - * @return void - */ - protected function startAcceptedObjectTypes () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); - } - - /** - * Starts hash from private key - * - * @return void - */ - protected function startPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes hash from private key - * - * @return void - */ - protected function finishPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes accepted object types - * - * @return void - */ - protected function finishAcceptedObjectTypes () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish data - * - * @return void - */ - protected function finishPublishData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish - * - * @return void - */ - protected function finishPublish () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } -} - -// [EOF] -?> diff --git a/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php index 84f1f95aa..19ef10e98 100644 --- a/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php +++ b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php @@ -7,8 +7,8 @@ use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemp // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; +use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate; /** * An RequestNodeList template engine class for XML templates @@ -33,7 +33,7 @@ use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable { // Constants for array elements const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; const REQUEST_DATA_SESSION_ID = 'session-id'; @@ -84,7 +84,7 @@ class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements * @return void * @todo Find something useful with this! */ - public function characterHandler ($resource, $characters) { + public function characterHandler ($resource, string $characters) { // Trim all spaces away $characters = trim($characters); @@ -166,7 +166,5 @@ class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements // Pop the last entry $this->getStackInstance()->popNamed('node_request_node_list'); } -} -// [EOF] -?> +} diff --git a/application/hub/config.php b/application/hub/config.php index e1e219258..bccfb4988 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -790,18 +790,6 @@ $cfg->setConfigEntry('tcp_socket_accept_wait_usec', 0); // CFG: NODE-STATE-CHECKED-PACKAGE-CLASS $cfg->setConfigEntry('node_state_checked_package_class', 'NewConnectionNodeState'); -// CFG: NODE-ID -$cfg->setConfigEntry('node_id', ''); - -// CFG: SESSION-ID -$cfg->setConfigEntry('session_id', ''); - -// CFG: PRIVATE-KEY -$cfg->setConfigEntry('private_key', ''); - -// CFG: PRIVATE-KEY-HASH -$cfg->setConfigEntry('private_key_hash', ''); - // CFG: EXTERNAL-ADDRESS $cfg->setConfigEntry('external_address', ''); diff --git a/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php b/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php index d531a43a3..ceb19add6 100644 --- a/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php +++ b/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php @@ -69,6 +69,6 @@ interface HandleableProtocol extends Handleable, HubInterface { * @param $unl UNL to test * @return $ifMatches Whether the found UNL matches own addresss */ - function isOwnAddress ($unl); + function isOwnAddress (string $unl); } diff --git a/core b/core index 90f442d88..74b4f2c17 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 90f442d88f7876a27ff75452e0ed1708b7dbc198 +Subproject commit 74b4f2c1770c622cbdbb1f84ac27771da18a0427