From: Roland Häder Date: Sun, 6 Dec 2020 11:24:23 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=57e7f91a5aba4faf1a7ad107b3e013ad926f94f2;hp=5dfec1886bc8db372483aa4f710c948f4fdc8027;p=core.git Continued: - replaced InvalidObjectException with InvalidArgumentException - that custom exception was already deprecated/unwanted anyway - moved classes to deeper packages Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/compressor/class_Bzip2Compressor.php b/framework/main/classes/compressor/class_Bzip2Compressor.php index 982b110d..bdfe5d96 100644 --- a/framework/main/classes/compressor/class_Bzip2Compressor.php +++ b/framework/main/classes/compressor/class_Bzip2Compressor.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Compressor\Bzip2; use Org\Mxchange\CoreFramework\Compressor\Compressor; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Load SPL stuff +use \InvalidArgumentException; + /** * BZIP2 compression and decompression class * @@ -52,7 +55,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) { // Compressor can maybe be used $compressorInstance = new Bzip2Compressor(); - } // END - if + } // Return the compressor instance return $compressorInstance; @@ -63,13 +66,14 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function compressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the compressed stream return bzcompress($streamData, 1); @@ -80,13 +84,14 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function decompressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Decompress it $streamData = bzdecompress($streamData, true); diff --git a/framework/main/classes/compressor/class_GzipCompressor.php b/framework/main/classes/compressor/class_GzipCompressor.php index 36f556e2..4a46ab89 100644 --- a/framework/main/classes/compressor/class_GzipCompressor.php +++ b/framework/main/classes/compressor/class_GzipCompressor.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Compressor\Gzip; use Org\Mxchange\CoreFramework\Compressor\Compressor; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Load SPL stuff +use \InvalidArgumentException; + /** * GZIP compression and decompression class * @@ -52,7 +55,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { if ((function_exists('gzencode')) && (function_exists('gzdecode'))) { // Compressor can maybe be used $compressorInstance = new GzipCompressor(); - } // END - if + } // Return the compressor instance return $compressorInstance; @@ -63,13 +66,14 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function compressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the compressed stream return gzencode($streamData, 1); @@ -80,13 +84,14 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function decompressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the decompressed stream return gzdecode($streamData); diff --git a/framework/main/classes/compressor/class_NullCompressor.php b/framework/main/classes/compressor/class_NullCompressor.php index a18a1a81..79e865dd 100644 --- a/framework/main/classes/compressor/class_NullCompressor.php +++ b/framework/main/classes/compressor/class_NullCompressor.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Compressor\Null; use Org\Mxchange\CoreFramework\Compressor\Compressor; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Load SPL stuff +use \InvalidArgumentException; + /** * Null compression and decompression class * @@ -57,13 +60,14 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function compressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the compressed stream return $streamData; @@ -74,13 +78,14 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function decompressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the decompressed stream return $streamData; diff --git a/framework/main/classes/compressor/class_ZlibCompressor.php b/framework/main/classes/compressor/class_ZlibCompressor.php index 79b88d5d..6e120a47 100644 --- a/framework/main/classes/compressor/class_ZlibCompressor.php +++ b/framework/main/classes/compressor/class_ZlibCompressor.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Compressor\Zlib; use Org\Mxchange\CoreFramework\Compressor\Compressor; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Load SPL stuff +use \InvalidArgumentException; + /** * ZLIB compression and decompression class * @@ -52,7 +55,7 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) { // Compressor can maybe be used $compressorInstance = new ZlibCompressor(); - } // END - if + } // Return the compressor instance return $compressorInstance; @@ -63,13 +66,14 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function compressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the compressed stream return gzcompress($streamData, 1); @@ -80,13 +84,14 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * * @param $streamData Mixed non-object stream data * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ public function decompressStream ($streamData) { - if (is_object($streamData)) { + // Validate parameter + if (is_object($streamData) || is_resource($streamData)) { // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if + throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData))); + } // Return the decompressed stream return gzuncompress($streamData); diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 56c0e214..7c2acb44 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -193,7 +193,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl * @param $filterChain Name of the filter chain * @return void */ - protected function initFilterChain ($filterChain) { + protected function initFilterChain (string $filterChain) { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START'); $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED'); @@ -207,7 +207,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl * @return void * @throws InvalidFilterChainException If the filter chain is invalid */ - protected function addFilter ($filterChain, Filterable $filterInstance) { + protected function addFilter (string $filterChain, Filterable $filterInstance) { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START'); // Test if the filter is there @@ -262,7 +262,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl * @return void * @throws InvalidFilterChainException If the filter chain is invalid */ - protected function executeFilters ($filterChain, Requestable $requestInstance, Responseable $responseInstance) { + protected function executeFilters (string $filterChain, Requestable $requestInstance, Responseable $responseInstance) { // Test if the filter is there if (!isset($this->filterChains[$filterChain])) { // Throw an exception here diff --git a/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php index 446e13a5..1201949f 100644 --- a/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php +++ b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php @@ -45,11 +45,12 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct (string $className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Initialize the cache instance $this->initCacheInstance(); diff --git a/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php b/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php deleted file mode 100644 index b119daaf..00000000 --- a/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php +++ /dev/null @@ -1,453 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * 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 XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableXmlTemplate { - // Load traits - use CompileableTemplateTrait; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @param $innerTemplateInstance A CompileableXmlTemplate instance - * @return $templateInstance An instance of TemplateEngine - */ - public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance) { - // Get a new instance - $templateInstance = new XmlRewriterTemplateDecorator(); - - // Set the inner template engine - $templateInstance->setTemplateInstance($innerTemplateInstance); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Settter for variable group - * - * @param $groupName Name of variable group - * @param $add Whether add this group - * @return void - */ - public function setVariableGroup (string $groupName, bool $add = true) { - // Call the inner class' method - $this->getTemplateInstance()->setVariableGroup($groupName, $add); - } - - /** - * Adds a variable to current group - * - * @param $variableName Variable to set - * @param $value Value to store in variable - * @return void - */ - public function addGroupVariable (string $variableName, $value) { - // Call the inner class' method - $this->getTemplateInstance()->addGroupVariable($variableName, $value); - } - - /** - * Getter for base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getTemplateBasePath () { - // Call the inner class' method - return $this->getTemplateInstance()->getTemplateBasePath(); - } - - /** - * Getter for generic base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getGenericBasePath () { - // Call the inner class' method - return $this->getTemplateInstance()->getGenericBasePath(); - } - - /** - * Getter for template extension - * - * @return $templateExtension The file extension for all uncompiled templates - */ - public final function getRawTemplateExtension () { - // Call the inner class' method - return $this->getTemplateInstance()->getRawTemplateExtension(); - } - - /** - * Getter for given variable group - * - * @param $variableGroup Variable group to check - * @return $varStack Found variable group - */ - public function getVarStack (string $variableGroup) { - // Call the inner class' method - return $this->getTemplateInstance()->getVarStack($variableGroup); - } - - /** - * Getter for code-template extension - * - * @return $codeExtension The file extension for all code templates - */ - public final function getCodeTemplateExtension () { - // Call the inner class' method - return $this->getTemplateInstance()->getCodeTemplateExtension(); - } - - /** - * Getter for template type - * - * @return $templateType The current template's type - */ - public final function getTemplateType () { - // Call the inner class' method - return $this->getTemplateInstance()->getTemplateType(); - } - - /** - * Assign (add) a given variable with a value - * - * @param $variableName The variable we are looking for - * @param $value The value we want to store in the variable - * @return void - */ - public function assignVariable (string $variableName, $value) { - // Call the inner class' method - $this->getTemplateInstance()->assignVariable($variableName, $value); - } - - /** - * Removes a given variable - * - * @param $variableName The variable we are looking for - * @param $variableGroup Name of variable group (default: 'general') - * @return void - */ - public function removeVariable (string $variableName, string $variableGroup = 'general') { - // Call the inner class' method - $this->getTemplateInstance()->removeVariable($variableName, $variableGroup); - } - - /** - * Load a specified HTML template into the engine - * - * @param $template The web template we shall load which is located in - * 'html' by default - * @return void - */ - public function loadHtmlTemplate (string $template) { - // Call the inner class' method - $this->getTemplateInstance()->loadHtmlTemplate($template); - } - - /** - * Assign a given congfiguration variable with a value - * - * @param $variableName The configuration variable we want to assign - * @return void - */ - public function assignConfigVariable (string $variableName) { - // Call the inner class' method - $this->getTemplateInstance()->assignConfigVariable($variableName); - } - - /** - * Load a specified code template into the engine - * - * @param $template The code template we shall load which is - * located in 'code' by default - * @return void - */ - public function loadCodeTemplate (string $template) { - // Call the inner class' method - $this->getTemplateInstance()->loadCodeTemplate($template); - } - - /** - * Load a specified email template into the engine for later compilation - * with other code/web/email templates. - * - * @param $template The email template we shall load which is - * located in "html" by default - * @return void - */ - public function loadEmailTemplate ($template) { - // Call the inner class' method - $this->getTemplateInstance()->loadEmailTemplate($template); - } - - /** - * Compiles configuration place-holders in all variables. This 'walks' - * through the variable stack 'general'. It interprets all values from that - * variables as configuration entries after compiling them. - * - * @return void - */ - public function compileConfigInVariables () { - // Call the inner class' method - $this->getTemplateInstance()->compileConfigInVariables(); - } - - /** - * Compile all variables by inserting their respective values - * - * @return void - */ - public function compileVariables () { - // Call the inner class' method - $this->getTemplateInstance()->compileVariables(); - } - - /** - * Compile all required templates into the current loaded one - * - * @return void - */ - public function compileTemplate () { - // Call the inner class' method - $this->getTemplateInstance()->compileTemplate(); - } - - /** - * Assigns the last loaded raw template content with a given variable - * - * @param $templateName Name of the template we want to assign - * @param $variableName Name of the variable we want to assign - * @return void - */ - public function assignTemplateWithVariable (string $templateName, string $variableName) { - // Call the inner class' method - $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName); - } - - /** - * Transfers the content of this template engine to a given response instance - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - public function transferToResponse (Responseable $responseInstance) { - // Call the inner class' method - $this->getTemplateInstance()->transportToResponse($responseInstance); - } - - /** - * Assigns all the application data with template variables - * - * @return void - */ - public function assignApplicationData () { - // Call the inner class' method - $this->getTemplateInstance()->assignApplicationData(); - } - - /** - * "Compiles" a variable by replacing {?var?} with it's content - * - * @param $rawCode Raw code to compile - * @param $setMatchAsCode Sets $match if readVariable() returns empty result - * @return $rawCode Compile code with inserted variable value - */ - public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) { - return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode); - } - - /** - * Getter for variable group array - * - * @return $variableGroups All variable groups - */ - public final function getVariableGroups () { - // Call the inner class' method - return $this->getTemplateInstance()->getVariableGroups(); - } - - /** - * Getter for raw template data - * - * @return $rawTemplateData The raw data from the template - */ - public function getRawTemplateData () { - // Call the inner class' method - return $this->getTemplateInstance()->getRawTemplateData(); - } - - /** - * Renames a variable in code and in stack - * - * @param $oldName Old name of variable - * @param $newName New name of variable - * @return void - */ - public function renameVariable (string $oldName, string $newName) { - // Call the inner class' method - $this->getTemplateInstance()->renameVariable($oldName, $newName); - } - - /** - * Renders the given XML content - * - * @param $content Valid XML content or if not set the current loaded raw content - * @return void - * @throws XmlParserException If an XML error was found - */ - public function renderXmlContent (string $content = NULL) { - // Call the inner class' method - $this->getTemplateInstance()->renderXmlContent($content); - } - - /** - * Enables or disables language support - * - * @param $languageSupport New language support setting - * @return void - */ - public function enableLanguageSupport (bool $languageSupport = true) { - // Call the inner class' method - $this->getTemplateInstance()->enableLanguageSupport($languageSupport); - } - - /** - * Checks whether language support is enabled - * - * @return $languageSupport Whether language support is enabled or disabled - */ - public function isLanguageSupportEnabled () { - // Call the inner class' method - return $this->getTemplateInstance()->isLanguageSupportEnabled(); - } - - /** - * Enables or disables XML compacting - * - * @param $xmlCompacting New XML compacting setting - * @return void - */ - public function enableXmlCompacting (bool $xmlCompacting = true) { - // Call the inner class' method - $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting); - } - - /** - * Checks whether XML compacting is enabled - * - * @return $xmlCompacting Whether XML compacting is enabled or disabled - */ - public function isXmlCompactingEnabled () { - // Call the inner class' method - return $this->getTemplateInstance()->isXmlCompactingEnabled(); - } - - /** - * 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 function startElement ($resource, string $element, array $attributes) { - // Call the inner class' method - $this->getTemplateInstance()->startElement($resource, $element, $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 function finishElement ($resource, string $nodeName) { - // Call the inner class' method - $this->getTemplateInstance()->finishElement($resource, $nodeName); - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, string $characters) { - // Call the inner class' method but trim the characters before - $this->getTemplateInstance()->characterHandler($resource, trim($characters)); - } - - /** - * Removes all comments, tabs and new-line charcters to compact the content - * - * @param $uncompactedContent The uncompacted content - * @return $compactedContent The compacted content - */ - public function compactContent (string $uncompactedContent) { - // Compact it ... - $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent); - - // ... and return it - return $compactedContent; - } - - /** - * Assigns a lot variables into the stack of currently loaded template. - * This method should only be used in very rare circumstances, e.g. when - * you have to copy a whole set of variables into the template engine. - * Before you use this method, please make sure you have considered all - * other possiblities. - * - * @param $variables An array with variables to be assigned - * @return void - */ - public function assignMultipleVariables (array $variables) { - // Call the inner class' method but trim the characters before - $this->getTemplateInstance()->assignMultipleVariables($variables); - } - -} diff --git a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php b/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php deleted file mode 100644 index db9cfce4..00000000 --- a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * 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 XmlCompactorDecorator extends BaseDecorator implements Parseable { - /** - * Instance of the parser class - */ - private $parserInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Parser and prepares it for usage - * - * @param $innerParserInstance A Parseable instance - * @return $parserInstance An instance of this parser - */ - public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) { - // Get a new instance - $parserInstance = new XmlCompactorDecorator(); - - // Get a new decorator instance for the template engine - $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance())); - - // Re-set the parser's template instance to the decorator instance - $innerParserInstance->setTemplateInstance($templateInstance); - - // Set the inner parser instance - $parserInstance->setParserInstance($innerParserInstance); - - // Return the prepared instance - return $parserInstance; - } - - /** - * Setter for Parseable instance - * - * @param $parserInstance An instance of an Parseable - * @return void - */ - protected final function setParserInstance (Parseable $parserInstance) { - $this->parserInstance = $parserInstance; - } - - /** - * Getter for Parseable instance - * - * @return $parserInstance An instance of an Parseable - */ - private final function getParserInstance () { - return $this->parserInstance; - } - - /** - * Parses the given XML content - * - * @param $content Valid XML content - * @return void - * @throws XmlCompactorDecoratorException If an XML error was found - */ - public function parseXmlContent ($content) { - // Remove all comments for better compacting - $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content); - - // Parse the content - $this->getParserInstance()->parseXmlContent($content); - } - -} diff --git a/framework/main/classes/decorator/xml/compactor/class_XmlCompactorDecorator.php b/framework/main/classes/decorator/xml/compactor/class_XmlCompactorDecorator.php new file mode 100644 index 00000000..23c125b2 --- /dev/null +++ b/framework/main/classes/decorator/xml/compactor/class_XmlCompactorDecorator.php @@ -0,0 +1,105 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * 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 XmlCompactorDecorator extends BaseDecorator implements Parseable { + /** + * Instance of the parser class + */ + private $parserInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Parser and prepares it for usage + * + * @param $innerParserInstance A Parseable instance + * @return $parserInstance An instance of this parser + */ + public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) { + // Get a new instance + $parserInstance = new XmlCompactorDecorator(); + + // Get a new decorator instance for the template engine + $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance())); + + // Re-set the parser's template instance to the decorator instance + $innerParserInstance->setTemplateInstance($templateInstance); + + // Set the inner parser instance + $parserInstance->setParserInstance($innerParserInstance); + + // Return the prepared instance + return $parserInstance; + } + + /** + * Setter for Parseable instance + * + * @param $parserInstance An instance of an Parseable + * @return void + */ + protected final function setParserInstance (Parseable $parserInstance) { + $this->parserInstance = $parserInstance; + } + + /** + * Getter for Parseable instance + * + * @return $parserInstance An instance of an Parseable + */ + private final function getParserInstance () { + return $this->parserInstance; + } + + /** + * Parses the given XML content + * + * @param $content Valid XML content + * @return void + * @throws XmlCompactorDecoratorException If an XML error was found + */ + public function parseXmlContent (string $content) { + // Remove all comments for better compacting + $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content); + + // Parse the content + $this->getParserInstance()->parseXmlContent($content); + } + +} diff --git a/framework/main/classes/decorator/xml/template/class_XmlRewriterTemplateDecorator.php b/framework/main/classes/decorator/xml/template/class_XmlRewriterTemplateDecorator.php new file mode 100644 index 00000000..b119daaf --- /dev/null +++ b/framework/main/classes/decorator/xml/template/class_XmlRewriterTemplateDecorator.php @@ -0,0 +1,453 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * 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 XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableXmlTemplate { + // Load traits + use CompileableTemplateTrait; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $innerTemplateInstance A CompileableXmlTemplate instance + * @return $templateInstance An instance of TemplateEngine + */ + public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance) { + // Get a new instance + $templateInstance = new XmlRewriterTemplateDecorator(); + + // Set the inner template engine + $templateInstance->setTemplateInstance($innerTemplateInstance); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Settter for variable group + * + * @param $groupName Name of variable group + * @param $add Whether add this group + * @return void + */ + public function setVariableGroup (string $groupName, bool $add = true) { + // Call the inner class' method + $this->getTemplateInstance()->setVariableGroup($groupName, $add); + } + + /** + * Adds a variable to current group + * + * @param $variableName Variable to set + * @param $value Value to store in variable + * @return void + */ + public function addGroupVariable (string $variableName, $value) { + // Call the inner class' method + $this->getTemplateInstance()->addGroupVariable($variableName, $value); + } + + /** + * Getter for base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getTemplateBasePath () { + // Call the inner class' method + return $this->getTemplateInstance()->getTemplateBasePath(); + } + + /** + * Getter for generic base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getGenericBasePath () { + // Call the inner class' method + return $this->getTemplateInstance()->getGenericBasePath(); + } + + /** + * Getter for template extension + * + * @return $templateExtension The file extension for all uncompiled templates + */ + public final function getRawTemplateExtension () { + // Call the inner class' method + return $this->getTemplateInstance()->getRawTemplateExtension(); + } + + /** + * Getter for given variable group + * + * @param $variableGroup Variable group to check + * @return $varStack Found variable group + */ + public function getVarStack (string $variableGroup) { + // Call the inner class' method + return $this->getTemplateInstance()->getVarStack($variableGroup); + } + + /** + * Getter for code-template extension + * + * @return $codeExtension The file extension for all code templates + */ + public final function getCodeTemplateExtension () { + // Call the inner class' method + return $this->getTemplateInstance()->getCodeTemplateExtension(); + } + + /** + * Getter for template type + * + * @return $templateType The current template's type + */ + public final function getTemplateType () { + // Call the inner class' method + return $this->getTemplateInstance()->getTemplateType(); + } + + /** + * Assign (add) a given variable with a value + * + * @param $variableName The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + */ + public function assignVariable (string $variableName, $value) { + // Call the inner class' method + $this->getTemplateInstance()->assignVariable($variableName, $value); + } + + /** + * Removes a given variable + * + * @param $variableName The variable we are looking for + * @param $variableGroup Name of variable group (default: 'general') + * @return void + */ + public function removeVariable (string $variableName, string $variableGroup = 'general') { + // Call the inner class' method + $this->getTemplateInstance()->removeVariable($variableName, $variableGroup); + } + + /** + * Load a specified HTML template into the engine + * + * @param $template The web template we shall load which is located in + * 'html' by default + * @return void + */ + public function loadHtmlTemplate (string $template) { + // Call the inner class' method + $this->getTemplateInstance()->loadHtmlTemplate($template); + } + + /** + * Assign a given congfiguration variable with a value + * + * @param $variableName The configuration variable we want to assign + * @return void + */ + public function assignConfigVariable (string $variableName) { + // Call the inner class' method + $this->getTemplateInstance()->assignConfigVariable($variableName); + } + + /** + * Load a specified code template into the engine + * + * @param $template The code template we shall load which is + * located in 'code' by default + * @return void + */ + public function loadCodeTemplate (string $template) { + // Call the inner class' method + $this->getTemplateInstance()->loadCodeTemplate($template); + } + + /** + * Load a specified email template into the engine for later compilation + * with other code/web/email templates. + * + * @param $template The email template we shall load which is + * located in "html" by default + * @return void + */ + public function loadEmailTemplate ($template) { + // Call the inner class' method + $this->getTemplateInstance()->loadEmailTemplate($template); + } + + /** + * Compiles configuration place-holders in all variables. This 'walks' + * through the variable stack 'general'. It interprets all values from that + * variables as configuration entries after compiling them. + * + * @return void + */ + public function compileConfigInVariables () { + // Call the inner class' method + $this->getTemplateInstance()->compileConfigInVariables(); + } + + /** + * Compile all variables by inserting their respective values + * + * @return void + */ + public function compileVariables () { + // Call the inner class' method + $this->getTemplateInstance()->compileVariables(); + } + + /** + * Compile all required templates into the current loaded one + * + * @return void + */ + public function compileTemplate () { + // Call the inner class' method + $this->getTemplateInstance()->compileTemplate(); + } + + /** + * Assigns the last loaded raw template content with a given variable + * + * @param $templateName Name of the template we want to assign + * @param $variableName Name of the variable we want to assign + * @return void + */ + public function assignTemplateWithVariable (string $templateName, string $variableName) { + // Call the inner class' method + $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName); + } + + /** + * Transfers the content of this template engine to a given response instance + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Call the inner class' method + $this->getTemplateInstance()->transportToResponse($responseInstance); + } + + /** + * Assigns all the application data with template variables + * + * @return void + */ + public function assignApplicationData () { + // Call the inner class' method + $this->getTemplateInstance()->assignApplicationData(); + } + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @param $setMatchAsCode Sets $match if readVariable() returns empty result + * @return $rawCode Compile code with inserted variable value + */ + public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) { + return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode); + } + + /** + * Getter for variable group array + * + * @return $variableGroups All variable groups + */ + public final function getVariableGroups () { + // Call the inner class' method + return $this->getTemplateInstance()->getVariableGroups(); + } + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + public function getRawTemplateData () { + // Call the inner class' method + return $this->getTemplateInstance()->getRawTemplateData(); + } + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + public function renameVariable (string $oldName, string $newName) { + // Call the inner class' method + $this->getTemplateInstance()->renameVariable($oldName, $newName); + } + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + public function renderXmlContent (string $content = NULL) { + // Call the inner class' method + $this->getTemplateInstance()->renderXmlContent($content); + } + + /** + * Enables or disables language support + * + * @param $languageSupport New language support setting + * @return void + */ + public function enableLanguageSupport (bool $languageSupport = true) { + // Call the inner class' method + $this->getTemplateInstance()->enableLanguageSupport($languageSupport); + } + + /** + * Checks whether language support is enabled + * + * @return $languageSupport Whether language support is enabled or disabled + */ + public function isLanguageSupportEnabled () { + // Call the inner class' method + return $this->getTemplateInstance()->isLanguageSupportEnabled(); + } + + /** + * Enables or disables XML compacting + * + * @param $xmlCompacting New XML compacting setting + * @return void + */ + public function enableXmlCompacting (bool $xmlCompacting = true) { + // Call the inner class' method + $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting); + } + + /** + * Checks whether XML compacting is enabled + * + * @return $xmlCompacting Whether XML compacting is enabled or disabled + */ + public function isXmlCompactingEnabled () { + // Call the inner class' method + return $this->getTemplateInstance()->isXmlCompactingEnabled(); + } + + /** + * 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 function startElement ($resource, string $element, array $attributes) { + // Call the inner class' method + $this->getTemplateInstance()->startElement($resource, $element, $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 function finishElement ($resource, string $nodeName) { + // Call the inner class' method + $this->getTemplateInstance()->finishElement($resource, $nodeName); + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, string $characters) { + // Call the inner class' method but trim the characters before + $this->getTemplateInstance()->characterHandler($resource, trim($characters)); + } + + /** + * Removes all comments, tabs and new-line charcters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ + public function compactContent (string $uncompactedContent) { + // Compact it ... + $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent); + + // ... and return it + return $compactedContent; + } + + /** + * Assigns a lot variables into the stack of currently loaded template. + * This method should only be used in very rare circumstances, e.g. when + * you have to copy a whole set of variables into the template engine. + * Before you use this method, please make sure you have considered all + * other possiblities. + * + * @param $variables An array with variables to be assigned + * @return void + */ + public function assignMultipleVariables (array $variables) { + // Call the inner class' method but trim the characters before + $this->getTemplateInstance()->assignMultipleVariables($variables); + } + +} diff --git a/framework/main/classes/factories/class_BaseFactory.php b/framework/main/classes/factories/class_BaseFactory.php index 1eea9ce9..5b16ef50 100644 --- a/framework/main/classes/factories/class_BaseFactory.php +++ b/framework/main/classes/factories/class_BaseFactory.php @@ -41,12 +41,12 @@ abstract class BaseFactory extends BaseFrameworkSystem { /** * Protected constructor * - * @param $fullClassName Name of the real class (not BaseFactory) + * @param $className Name of the real class (not BaseFactory) * @return void */ - protected function __construct ($fullClassName) { + protected function __construct (string $className) { // Call parent constructor - parent::__construct($fullClassName); + parent::__construct($className); } /** @@ -54,15 +54,15 @@ abstract class BaseFactory extends BaseFrameworkSystem { * * @param $fullClassName Name of the class we shall count */ - protected static final function countObject ($fullClassName) { + protected static final function countObject (string $fullClassName) { // Count it up in total sum self::$total++; // Do we have an entry? - if (!isset(self::$objectCounters[$fullClassName])) { + if (!self::isClassCounted($fullClassName)) { // No, then generate one self::$objectCounters[$fullClassName] = 0; - } // END - if + } // Count it up again //* NOISY-DEBUG: */ print __METHOD__.': className=' .$fullClassName . PHP_EOL; @@ -87,4 +87,15 @@ abstract class BaseFactory extends BaseFrameworkSystem { return self::$objectCounters; } + /** + * Checks whether given full class name is already counted + * + * @param $fullClassName Full name of class + * @return $isCounted Whether given class name is counted + */ + protected static final function isClassCounted (string $fullClassName) { + // Return isset() result + return isset(self::$objectCounters[$fullClassName]); + } + } diff --git a/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php index 8df8c285..6848cf36 100644 --- a/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php +++ b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php @@ -46,7 +46,7 @@ class DatabaseFrontendFactory extends ObjectFactory { * * @return $frontendInstance A database frontend instance */ - public static final function createFrontendByConfiguredName ($frontendName) { + public static final function createFrontendByConfiguredName (string $frontendName) { // Get registry instance $registryInstance = GenericRegistry::getRegistry(); diff --git a/framework/main/classes/factories/html/class_HtmlNewsFactory.php b/framework/main/classes/factories/html/class_HtmlNewsFactory.php index da522134..ebcd9ff4 100644 --- a/framework/main/classes/factories/html/class_HtmlNewsFactory.php +++ b/framework/main/classes/factories/html/class_HtmlNewsFactory.php @@ -67,8 +67,8 @@ class HtmlNewsFactory extends BaseFactory { if (!empty($action)) { // Then use both for config entry $configEntry = sprintf('news_reader_%s_%s_class', $command, $action); - } // END - if - } // END - if + } + } // Get the news reader class name from config $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry); diff --git a/framework/main/classes/factories/index/class_FileStackIndexFactory.php b/framework/main/classes/factories/index/class_FileStackIndexFactory.php index b24f2884..51de21d6 100644 --- a/framework/main/classes/factories/index/class_FileStackIndexFactory.php +++ b/framework/main/classes/factories/index/class_FileStackIndexFactory.php @@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; // Import SPL stuff +use \InvalidArgumentException; use \SplFileInfo; /** @@ -47,10 +48,14 @@ class FileStackIndexFactory extends ObjectFactory { * * @param $infoInstance An instance of a SplFileInfo class * @return $indexInstance An instance of a IndexableStack class + * @throws InvalidArgumentException If a parameter is invalid */ public static final function createFileStackIndexInstance (SplFileInfo $infoInstance, string $type) { // If there is no handler? - if (GenericRegistry::getRegistry()->instanceExists($type . '_index')) { + if (empty($type)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "type" is empty'); + } elseif (GenericRegistry::getRegistry()->instanceExists($type . '_index')) { // Get handler from registry $indexInstance = GenericRegistry::getRegistry()->getInstance($type . '_index'); } else { diff --git a/framework/main/classes/factories/objects/class_ObjectFactory.php b/framework/main/classes/factories/objects/class_ObjectFactory.php index b10907b5..c081b6bd 100644 --- a/framework/main/classes/factories/objects/class_ObjectFactory.php +++ b/framework/main/classes/factories/objects/class_ObjectFactory.php @@ -35,12 +35,12 @@ class ObjectFactory extends BaseFactory { /** * Protected constructor * - * @param $fullClassName Name of this class + * @param $className Name of this class * @return void */ - protected function __construct ($fullClassName = __CLASS__) { + protected function __construct (string $className = __CLASS__) { // Call parent constructor - parent::__construct($fullClassName); + parent::__construct($className); } /** @@ -48,18 +48,18 @@ class ObjectFactory extends BaseFactory { * the class was not found. No parameters for the object are currently * supported. * - * @param $fullClassName Name of the class we shall construct + * @param $fullClassName Name of the class we shall construct * @param $args Arguments in an indexed array * @return $objectInstance An instance of the requested object * @throws NoClassException If the requested class was not found * @throws InvalidArgumentException If className is empty or the name not following naming-convention */ - public static final function createObjectByName ($fullClassName, array $args = []) { + public static final function createObjectByName (string $fullClassName, array $args = []) { // Is the class name valid and is the class there? if (empty($fullClassName)) { // Throw an exception here - throw new InvalidArgumentException('Parameter "className" is empty'); - } elseif (!class_exists($fullClassName)) { + throw new InvalidArgumentException('Parameter "fullClassName" is empty'); + } elseif (!self::isClassCounted($fullClassName) && !class_exists($fullClassName)) { // First get an instance of this factory $factoryInstance = new ObjectFactory(); @@ -74,13 +74,13 @@ class ObjectFactory extends BaseFactory { if (count($classNameParts) < 4) { // Namespaces are missing throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Tld\Domain\Project\Package[\SubPackage...]\SomeFooBar', $fullClassName)); - } // END - if + } // Create method name $methodName = sprintf('create%s', self::stripNamespaceFromClassName($fullClassName)); // Run the user function - $objectInstance = call_user_func_array(array($fullClassName, $methodName), $args); + $objectInstance = call_user_func_array([$fullClassName, $methodName], $args); // Count this one up self::countObject($fullClassName); @@ -92,13 +92,13 @@ class ObjectFactory extends BaseFactory { /** * Creates an object by it's configured name * - * @param $configEnttry Configuration entry to read + * @param $configKey Configuration key to read * @param $args Arguments in an indexed array * @return $objectInstance An instance of the requested object */ - public static final function createObjectByConfiguredName ($configEntry, array $args = []) { + public static final function createObjectByConfiguredName (string $configKey, array $args = []) { // Read the configuration entry - $fullClassName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry); + $fullClassName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey); // Send this to the other factory... $objectInstance = self::createObjectByName($fullClassName, $args); @@ -115,7 +115,7 @@ class ObjectFactory extends BaseFactory { * @param $fullClassName Class name with namespace * @return $shortClassName Stripped class name (no namespace) */ - private static function stripNamespaceFromClassName ($fullClassName) { + private static function stripNamespaceFromClassName (string $fullClassName) { // The class name should contain at least 2 back-slashes, so split at them $classNameParts = explode("\\", $fullClassName); diff --git a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php index 172550a6..04f8fce7 100644 --- a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php +++ b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php @@ -46,17 +46,17 @@ class XmlTemplateEngineFactory extends ObjectFactory { * the registry it will be returned, else a new instance is created and * stored in the same registry entry. * - * @param $configEntry Config entry name for the template engine + * @param $configKey Config entry name for the template engine * @return $templateInstance A template engine instance */ - public static final function createXmlTemplateEngineInstance (string $configEntry) { + public static final function createXmlTemplateEngineInstance (string $configKey) { // Do we have an instance in the registry? - if (GenericRegistry::getRegistry()->instanceExists($configEntry)) { + if (GenericRegistry::getRegistry()->instanceExists($configKey)) { // Then use this instance - $templateInstance = GenericRegistry::getRegistry()->getInstance($configEntry); + $templateInstance = GenericRegistry::getRegistry()->getInstance($configKey); } else { - // Now prepare the tags instance - $templateInstance = ObjectFactory::createObjectByConfiguredName($configEntry); + // Get the XML template instance + $templateInstance = ObjectFactory::createObjectByConfiguredName($configKey); // Disable language support $templateInstance->enableLanguageSupport(false); @@ -68,7 +68,7 @@ class XmlTemplateEngineFactory extends ObjectFactory { $templateInstance->enableXmlCompacting(); // Set the instance in registry for further use - GenericRegistry::getRegistry()->addInstance($configEntry, $templateInstance); + GenericRegistry::getRegistry()->addInstance($configKey, $templateInstance); } // Return the instance diff --git a/framework/main/exceptions/main/class_InvalidObjectException.php b/framework/main/exceptions/main/class_InvalidObjectException.php deleted file mode 100644 index 7b55f5e9..00000000 --- a/framework/main/exceptions/main/class_InvalidObjectException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @deprecated Don't use this anymore - * - * 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 InvalidObjectException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, int $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Object is not allowed here.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/framework/main/interfaces/compressor/class_Compressor.php b/framework/main/interfaces/compressor/class_Compressor.php index ae996719..df7ac71b 100644 --- a/framework/main/interfaces/compressor/class_Compressor.php +++ b/framework/main/interfaces/compressor/class_Compressor.php @@ -33,7 +33,7 @@ interface Compressor extends FrameworkInterface { * * @param $streamData Mixed non-object stream data * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ function compressStream ($streamData); @@ -42,7 +42,7 @@ interface Compressor extends FrameworkInterface { * * @param $streamData Mixed non-object stream data * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object + * @throws InvalidArgumentException If the stream is not compressable or decompressable */ function decompressStream ($streamData);