From 7ddfbd1dcec6b308734e5282e86a8f87e837b093 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 2 Dec 2020 07:04:10 +0100 Subject: [PATCH] Continued: - introduced new traits - moved BaseXmlTemplateEngine to core framework - convert old array() to "new" [] scheme - updated core frameworks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../cruncher/class_BaseHubCruncher.php | 4 +- .../hub/classes/decoder/class_BaseDecoder.php | 29 +- application/hub/classes/dht/class_BaseDht.php | 31 +- .../handler/chunks/class_ChunkHandler.php | 4 +- .../classes/handler/class_BaseHubHandler.php | 29 +- .../package/class_NetworkPackageHandler.php | 5 +- .../hub/classes/miner/class_BaseHubMiner.php | 4 +- .../assembler/class_PackageAssembler.php | 27 +- .../classes/source/class_BaseUrlSource.php | 29 +- .../template/class_BaseXmlTemplateEngine.php | 373 ------------------ .../class_XmlAnnouncementTemplateEngine.php | 2 +- ...ss_XmlAnnouncementAnswerTemplateEngine.php | 0 .../classes/template/{ => xml}/answer/class_ | 0 .../class_BaseXmlAnswerTemplateEngine.php | 2 +- ...ss_XmlDhtBootstrapAnswerTemplateEngine.php | 0 ...XmlRequestNodeListAnswerTemplateEngine.php | 0 .../hub/classes/template/{ => xml}/class_ | 0 .../class_XmlSelfConnectTemplateEngine.php | 2 +- .../class_XmlDhtBootstrapTemplateEngine.php | 2 +- ..._XmlRequestNodeListEntryTemplateEngine.php | 2 +- .../class_XmlObjectRegistryTemplateEngine.php | 2 +- ...lass_XmlCruncherTestUnitTemplateEngine.php | 2 +- ...class_XmlDhtPublishEntryTemplateEngine.php | 2 +- ...class_XmlRequestNodeListTemplateEngine.php | 2 +- core | 2 +- 25 files changed, 37 insertions(+), 518 deletions(-) delete mode 100644 application/hub/classes/template/class_BaseXmlTemplateEngine.php rename application/hub/classes/template/{ => xml}/announcement/class_XmlAnnouncementTemplateEngine.php (99%) rename application/hub/classes/template/{ => xml}/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php (100%) rename application/hub/classes/template/{ => xml}/answer/class_ (100%) rename application/hub/classes/template/{ => xml}/answer/class_BaseXmlAnswerTemplateEngine.php (96%) rename application/hub/classes/template/{ => xml}/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php (100%) rename application/hub/classes/template/{ => xml}/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php (100%) rename application/hub/classes/template/{ => xml}/class_ (100%) rename application/hub/classes/template/{ => xml}/connect/class_XmlSelfConnectTemplateEngine.php (98%) rename application/hub/classes/template/{ => xml}/dht/class_XmlDhtBootstrapTemplateEngine.php (99%) rename application/hub/classes/template/{ => xml}/entries/class_XmlRequestNodeListEntryTemplateEngine.php (98%) rename application/hub/classes/template/{ => xml}/objects/class_XmlObjectRegistryTemplateEngine.php (99%) rename application/hub/classes/template/{ => xml}/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php (99%) rename application/hub/classes/template/{ => xml}/publish/class_XmlDhtPublishEntryTemplateEngine.php (99%) rename application/hub/classes/template/{ => xml}/requests/class_XmlRequestNodeListTemplateEngine.php (98%) diff --git a/application/hub/classes/cruncher/class_BaseHubCruncher.php b/application/hub/classes/cruncher/class_BaseHubCruncher.php index cf0762825..949c24b0a 100644 --- a/application/hub/classes/cruncher/class_BaseHubCruncher.php +++ b/application/hub/classes/cruncher/class_BaseHubCruncher.php @@ -174,10 +174,10 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('cruncher_buffer_stacker_class'); // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( + $this->bufferInstance->initStacks([ self::STACKER_NAME_IN_QUEUE, self::STACKER_NAME_OUT_QUEUE - )); + ]); // Output debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRUNCHER: All buffers are now initialized.'); diff --git a/application/hub/classes/decoder/class_BaseDecoder.php b/application/hub/classes/decoder/class_BaseDecoder.php index b6af54381..9849337d6 100644 --- a/application/hub/classes/decoder/class_BaseDecoder.php +++ b/application/hub/classes/decoder/class_BaseDecoder.php @@ -8,7 +8,7 @@ use Org\Shipsimu\Hub\Network\Delivery\Deliverable; // Import framework stuff use Org\Mxchange\CoreFramework\Handler\Handleable; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general Decoder class @@ -33,16 +33,14 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseDecoder extends BaseHubSystem { + // Load traits + use StackableTrait; + /** * A network package handler instance */ private $packageHandlerInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Handler instance */ @@ -78,25 +76,6 @@ abstract class BaseDecoder extends BaseHubSystem { return $this->packageHandlerInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Setter for handler instance * diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index 7a663cd12..ffe9e0d3e 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -12,7 +12,7 @@ use Org\Shipsimu\Hub\Helper\Dht\HelpableDht; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; /** @@ -40,6 +40,7 @@ use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; abstract class BaseDht extends BaseHubSystem implements Distributable { // Load traits use StateableTrait; + use StackableTrait; /** * Stacker name for "INSERT" node data @@ -52,11 +53,6 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { */ private $publishHelperInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -80,25 +76,6 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { DhtStateFactory::createDhtStateInstanceByName('init', $this); } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Initializes all stackers * @@ -106,10 +83,10 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { */ private function initStacks () { // Initialize all stacker - $this->getStackInstance()->initStacks(array( + $this->getStackInstance()->initStacks([ self::STACKER_NAME_INSERT_NODE, self::STACKER_NAME_PENDING_PUBLISHING, - )); + ]); } /** diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index a23f91294..26f0e7d40 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -126,11 +126,11 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera // Init all stacker /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: Initializing stackInstance=%s ...', $stackInstance->__toString())); - $stackInstance->initStacks(array( + $stackInstance->initStacks([ self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, self::STACKER_NAME_ASSEMBLED_RAW_DATA - )); + ]); // Set the stacker in this handler $handlerInstance->setStackInstance($stackInstance); diff --git a/application/hub/classes/handler/class_BaseHubHandler.php b/application/hub/classes/handler/class_BaseHubHandler.php index eef5130f4..b9b301a0d 100644 --- a/application/hub/classes/handler/class_BaseHubHandler.php +++ b/application/hub/classes/handler/class_BaseHubHandler.php @@ -15,7 +15,7 @@ use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\BaseHandler; use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Register; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general hub handler @@ -40,6 +40,9 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInterface { + // Load traits + use StackableTrait; + /** * Listener instance */ @@ -70,11 +73,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte */ private $registryInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -202,23 +200,4 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte return $this->registryInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - } diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index bd011d371..4bc52231c 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -42,6 +42,7 @@ use Org\Mxchange\CoreFramework\Socket\InvalidSocketException; use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait; use Org\Mxchange\CoreFramework\Traits\Visitor\VisitorTrait; use Org\Mxchange\CoreFramework\Visitor\Visitable; +use Org\Mxchange\CoreFramework\Visitor\Visitor; // Import SPL stuff use \BadMethodCallException; @@ -423,7 +424,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ protected function initStacks ($forceReInit = FALSE) { // Initialize all - $this->getStackInstance()->initStacks(array( + $this->getStackInstance()->initStacks([ self::STACKER_NAME_UNDECLARED, self::STACKER_NAME_DECLARED, self::STACKER_NAME_OUTGOING, @@ -434,7 +435,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei self::STACKER_NAME_NEW_MESSAGE, self::STACKER_NAME_PROCESSED_MESSAGE, self::STACKER_NAME_OUTGOING_STREAM - ), $forceReInit); + ], $forceReInit); } /** diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php index 6f6d0fb50..efc25d476 100644 --- a/application/hub/classes/miner/class_BaseHubMiner.php +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -190,10 +190,10 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('miner_buffer_stacker_class'); // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( + $this->bufferInstance->initStacks([ self::STACKER_NAME_IN_QUEUE, self::STACKER_NAME_OUT_QUEUE - )); + ]); // Output debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MINER: All buffers are now initialized.'); diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index b6611b8ad..eb7f3bf62 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -18,7 +18,7 @@ use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Registerable; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; use Org\Mxchange\CoreFramework\Traits\Stream\Input\InputStreamTrait; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -53,6 +53,7 @@ use \BadMethodCallException; class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, Visitable { // Load traits use InputStreamTrait; + use StackableTrait; /** * Name for stacker holding raw data of multiple messages @@ -79,11 +80,6 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, */ private $packageHandlerInstance = NULL; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Handler instance */ @@ -166,25 +162,6 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, return $this->packageHandlerInstance; } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Setter for handler instance * diff --git a/application/hub/classes/source/class_BaseUrlSource.php b/application/hub/classes/source/class_BaseUrlSource.php index 3026f5ece..9b521d10b 100644 --- a/application/hub/classes/source/class_BaseUrlSource.php +++ b/application/hub/classes/source/class_BaseUrlSource.php @@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Crawler\Source\BaseSource; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Stack\FileStackFactory; -use Org\Mxchange\CoreFramework\Stacker\Stackable; +use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait; /** * A general URL source class @@ -32,6 +32,9 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable; * along with this program. If not, see . */ abstract class BaseUrlSource extends BaseSource { + // Load traits + use StackableTrait; + // Stack name for all URLs const STACKER_NAME_URLS = 'urls'; @@ -40,11 +43,6 @@ abstract class BaseUrlSource extends BaseSource { const CRAWL_JOB_ARRAY_DEPTH = 'start_depth'; const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth'; - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - /** * Protected constructor * @@ -56,25 +54,6 @@ abstract class BaseUrlSource extends BaseSource { parent::__construct($className); } - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - protected final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - /** * Initalizes this source * diff --git a/application/hub/classes/template/class_BaseXmlTemplateEngine.php b/application/hub/classes/template/class_BaseXmlTemplateEngine.php deleted file mode 100644 index c9e34b3b4..000000000 --- a/application/hub/classes/template/class_BaseXmlTemplateEngine.php +++ /dev/null @@ -1,373 +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 . - */ -abstract class BaseXmlTemplateEngine extends BaseTemplateEngine { - /** - * Main nodes in the XML tree - */ - private $mainNodes = []; - - /** - * Sub nodes in the XML tree - */ - private $subNodes = []; - - /** - * Current main node - */ - private $curr = []; - - /** - * XML template type - */ - private $xmlTemplateType = 'xml'; - - /** - * Type prefix - */ - private $typePrefix = 'xml'; - - /** - * Name of stacker - */ - private $stackerName = ''; - - /** - * Content from dependency - */ - protected $dependencyContent = []; - - /** - * Template engine instance - */ - private $templateInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct (string $className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Does a generic initialization of the template engine - * - * @param $typePrefix Type prefix - * @param $xmlTemplateType Type of XML template - * @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 - */ - protected function initXmlTemplateEngine ($typePrefix, $xmlTemplateType) { - // Set XML template type and prefix - $this->xmlTemplateType = $xmlTemplateType; - $this->typePrefix = $typePrefix; - - // Get template instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); - - // Determine base path - $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($this, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($this, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $this->setTemplateBasePath($templateBasePath); - - // Set template extensions - $this->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension')); - $this->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($typePrefix . '_message_template_extension')); - - // Absolute output path for compiled templates - $this->setCompileOutputPath(sprintf('%s%s', - $templateBasePath, - FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path') - )); - - // Init a variable stacker - $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); - - // Set name - $this->stackerName = $typePrefix . '_' . $xmlTemplateType; - - // Init stacker - $stackInstance->initStack($this->stackerName); - - // Set it - $this->setStackInstance($stackInstance); - - // Set it in main nodes - array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType)); - } - - /** - * Load a specified XML template into the engine - * - * @param $templateName Optional name of template - * @return void - */ - public function loadXmlTemplate ($templateName = '') { - // Is the template name empty? - if (empty($templateName)) { - // Set generic template name - $templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type'; - } // END - if - - // Set template type - $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($templateName)); - - // Load the special template - $this->loadTemplate($this->xmlTemplateType); - } - - /** - * Getter for current main node - * - * @return $currMainNode Current main node - */ - public final function getCurrMainNode () { - return $this->curr['main_node']; - } - - /** - * Setter for current main node - * - * @param $element Element name to set as current main node - * @return $currMainNode Current main node - */ - private final function setCurrMainNode ($element) { - $this->curr['main_node'] = (string) $element; - } - - /** - * Getter for main node array - * - * @return $mainNodes Array with valid main node names - */ - public final function getMainNodes () { - return $this->mainNodes; - } - - /** - * Getter for stacker name - * - * @return $stackerName Name of stacker of this class - */ - protected final function getStackerName () { - return $this->stackerName; - } - - /** - * Setter for sub node array - * - * @param $subNodes Array with valid sub node names - * @return void - */ - public final function setSubNodes (array $subNodes) { - $this->subNodes = $subNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Setter for template engine instances - * - * @param $templateInstance An instance of a template engine class - * @return void - */ - protected final function setTemplateInstance (CompileableTemplate $templateInstance) { - $this->templateInstance = $templateInstance; - } - - /** - * Getter for template engine instances - * - * @return $templateInstance An instance of a template engine class - */ - protected final function getTemplateInstance () { - return $this->templateInstance; - } - - /** - * Read XML variables by calling readVariable() with 'general' as - * variable stack. - * - * @param $key Key to read from - * @return $value Value from variable - */ - public function readXmlData (string $key) { - // Is key parameter valid? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-XML-TEMPLATE-ENGINE: key=%s - CALLED!', $key)); - if (empty($key)) { - // Throw exception - throw new InvalidArgumentException('Parameter key is empty'); - } - - // Read the variable - $value = parent::readVariable($key, 'general'); - - // Is this null? - if (is_null($value)) { - // Bah, needs fixing. - $this->debugInstance(sprintf('[%s:%d]: key=%s returns NULL', __METHOD__, __LINE__, $key)); - } // END - if - - // Return value - return $value; - } - - /** - * Handles the template dependency for given XML node - * - * @param $node The XML node we should load a dependency template - * @param $templateDependency A template to load to satisfy dependencies - * @return void - */ - protected function handleTemplateDependency ($node, $templateDependency) { - // Check that the XML node is not empty - assert(!empty($node)); - - // Is the template dependency set? - if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { - // Get a temporay template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . self::convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class'); - - // Then load it - $templateInstance->loadXmlTemplate($templateDependency); - - // Parse the XML content - $templateInstance->renderXmlContent(); - - // Save the parsed raw content in our dependency array - $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); - } // END - if - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public final function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'init' . StringUtils::convertToClassName($this->xmlTemplateType); - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->getMainNodes())) { - // Okay, main node found! - $methodName = 'start' . StringUtils::convertToClassName($element); - - // Set it - $this->setCurrMainNode($element); - } elseif (in_array($element, $this->getSubNodes())) { - // Sub node found - $methodName = 'start' . StringUtils::convertToClassName($element); - } else { - // Invalid node name found - throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); - } - - // Call method - call_user_func_array(array($this, $methodName), $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public final function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { - // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } // END - if - - // Construct method name - $methodName = 'finish' . StringUtils::convertToClassName($nodeName); - - // Call the corresponding method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), array()); - } - -} diff --git a/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php similarity index 99% rename from application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php rename to application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php index 3c4ebbf4e..272dac68a 100644 --- a/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Announcement; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An Announcement template engine class for XML templates diff --git a/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php similarity index 100% rename from application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php rename to application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php diff --git a/application/hub/classes/template/answer/class_ b/application/hub/classes/template/xml/answer/class_ similarity index 100% rename from application/hub/classes/template/answer/class_ rename to application/hub/classes/template/xml/answer/class_ diff --git a/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php similarity index 96% rename from application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php rename to application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php index f5f2e3961..4d5eea307 100644 --- a/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/class_BaseXmlAnswerTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An generic answer template engine class for XML templates diff --git a/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php similarity index 100% rename from application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php rename to application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php diff --git a/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php similarity index 100% rename from application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php rename to application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php diff --git a/application/hub/classes/template/class_ b/application/hub/classes/template/xml/class_ similarity index 100% rename from application/hub/classes/template/class_ rename to application/hub/classes/template/xml/class_ diff --git a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php similarity index 98% rename from application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php rename to application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php index 19324f43a..eaf2ec1b8 100644 --- a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php @@ -4,11 +4,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\SelfConnect; // Import application-specific stuff use Org\Shipsimu\Hub\Tag\Tagable; -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An SelfConnect template engine class for XML templates diff --git a/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php similarity index 99% rename from application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php rename to application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php index 002841fa2..ea51a1f55 100644 --- a/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php +++ b/application/hub/classes/template/xml/dht/class_XmlDhtBootstrapTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An Bootstrap template engine class for XML templates diff --git a/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php similarity index 98% rename from application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php rename to application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php index 26e61b94b..aff38500b 100644 --- a/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php +++ b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An RequestNodeListEntry template engine class for XML templates diff --git a/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php similarity index 99% rename from application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php rename to application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php index 65ab2fef9..5edc06dbd 100644 --- a/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php +++ b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php @@ -4,12 +4,12 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\ObjectRegistry; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Registry\Object\ObjectTypeRegistryFactory; -use Org\Shipsimu\Hub\Template\Engine\Xml\BaseXmlTemplateEngine; // 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; /** * An ObjectRegistry template engine class for XML templates diff --git a/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php similarity index 99% rename from application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php rename to application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php index 7d4f0bf6d..36b805bb2 100644 --- a/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Cruncher\Template\Engine\Xml\TestUnit; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An TestUnit template engine class for XML templates diff --git a/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php similarity index 99% rename from application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php rename to application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php index ab3a6aa55..4f818bf75 100644 --- a/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ b/application/hub/classes/template/xml/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -3,11 +3,11 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Publish; // Import application-specific stuff -use Org\Shipsimu\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\Engine\Xml\BaseXmlTemplateEngine; /** * An PublishEntry template engine class for XML templates diff --git a/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php similarity index 98% rename from application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php rename to application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php index c1baf3a90..84f1f95aa 100644 --- a/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php +++ b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php @@ -3,12 +3,12 @@ namespace Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList; // Import application-specific stuff -use Org\Shipsimu\Hub\Template\Engine\Xml\BaseXmlTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemplateEngine; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Template\CompileableTemplate; +use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine; /** * An RequestNodeList template engine class for XML templates diff --git a/core b/core index 575accd32..a535464e9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 575accd328d27eccb2bf3caddb564b291e0780df +Subproject commit a535464e99d3baa2b50830bdf57074db2f14340a -- 2.39.5