From: Roland Häder Date: Sat, 7 Nov 2020 20:41:47 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=39c850365e53c2a80561dbc2e0da16093c246b49;p=core.git Continued: - added missing $templateInstance and getter/setter Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php b/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php index 760fe99f..63735c79 100644 --- a/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php +++ b/framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php @@ -31,6 +31,11 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * along with this program. If not, see . */ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate { + /** + * Template engine instance + */ + private $templateInstance = NULL; + /** * Protected constructor * @@ -58,6 +63,25 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT return $templateInstance; } + /** + * 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; + } + /** * Settter for variable group * @@ -65,7 +89,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $add Whether add this group * @return void */ - public function setVariableGroup ($groupName, $add = true) { + public function setVariableGroup (string $groupName, bool $add = true) { // Call the inner class' method $this->getTemplateInstance()->setVariableGroup($groupName, $add); } @@ -73,13 +97,13 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT /** * Adds a variable to current group * - * @param $var Variable to set + * @param $variableName Variable to set * @param $value Value to store in variable * @return void */ - public function addGroupVariable ($var, $value) { + public function addGroupVariable (string $variableName, $value) { // Call the inner class' method - $this->getTemplateInstance()->addGroupVariable($var, $value); + $this->getTemplateInstance()->addGroupVariable($variableName, $value); } /** @@ -118,7 +142,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $variableGroup Variable group to check * @return $varStack Found variable group */ - public function getVarStack ($variableGroup) { + public function getVarStack (string $variableGroup) { // Call the inner class' method return $this->getTemplateInstance()->getVarStack($variableGroup); } @@ -146,13 +170,13 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT /** * Assign (add) a given variable with a value * - * @param $var The variable we are looking for + * @param $variableName The variable we are looking for * @param $value The value we want to store in the variable * @return void */ - public function assignVariable ($var, $value) { + public function assignVariable (string $variableName, $value) { // Call the inner class' method - $this->getTemplateInstance()->assignVariable($var, $value); + $this->getTemplateInstance()->assignVariable($variableName, $value); } /** @@ -162,7 +186,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $variableGroup Name of variable group (default: 'general') * @return void */ - public function removeVariable ($variableName, $variableGroup = 'general') { + public function removeVariable (string $variableName, string $variableGroup = 'general') { // Call the inner class' method $this->getTemplateInstance()->removeVariable($variableName, $variableGroup); } @@ -174,7 +198,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * 'html' by default * @return void */ - public function loadHtmlTemplate ($template) { + public function loadHtmlTemplate (string $template) { // Call the inner class' method $this->getTemplateInstance()->loadHtmlTemplate($template); } @@ -185,7 +209,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $variableName The configuration variable we want to assign * @return void */ - public function assignConfigVariable ($variableName) { + public function assignConfigVariable (string $variableName) { // Call the inner class' method $this->getTemplateInstance()->assignConfigVariable($variableName); } @@ -197,7 +221,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * located in 'code' by default * @return void */ - public function loadCodeTemplate ($template) { + public function loadCodeTemplate (string $template) { // Call the inner class' method $this->getTemplateInstance()->loadCodeTemplate($template); } @@ -254,7 +278,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $variableName Name of the variable we want to assign * @return void */ - public function assignTemplateWithVariable ($templateName, $variableName) { + public function assignTemplateWithVariable (string $templateName, string $variableName) { // Call the inner class' method $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName); } @@ -287,7 +311,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $setMatchAsCode Sets $match if readVariable() returns empty result * @return $rawCode Compile code with inserted variable value */ - public function compileRawCode ($rawCode, $setMatchAsCode = false) { + public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) { return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode); } @@ -318,7 +342,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $newName New name of variable * @return void */ - public function renameVariable ($oldName, $newName) { + public function renameVariable (string $oldName, string $newName) { // Call the inner class' method $this->getTemplateInstance()->renameVariable($oldName, $newName); } @@ -330,7 +354,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @return void * @throws XmlParserException If an XML error was found */ - public function renderXmlContent ($content = NULL) { + public function renderXmlContent (string $content = NULL) { // Call the inner class' method $this->getTemplateInstance()->renderXmlContent($content); } @@ -341,7 +365,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $languageSupport New language support setting * @return void */ - public function enableLanguageSupport ($languageSupport = true) { + public function enableLanguageSupport (bool $languageSupport = true) { // Call the inner class' method $this->getTemplateInstance()->enableLanguageSupport($languageSupport); } @@ -362,7 +386,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $xmlCompacting New XML compacting setting * @return void */ - public function enableXmlCompacting ($xmlCompacting = true) { + public function enableXmlCompacting (bool $xmlCompacting = true) { // Call the inner class' method $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting); } @@ -386,7 +410,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @return void * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found */ - public function startElement ($resource, $element, array $attributes) { + public function startElement ($resource, string $element, array $attributes) { // Call the inner class' method $this->getTemplateInstance()->startElement($resource, $element, $attributes); } @@ -399,7 +423,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @return void * @throws XmlNodeMismatchException If current main node mismatches the closing one */ - public function finishElement ($resource, $nodeName) { + public function finishElement ($resource, string $nodeName) { // Call the inner class' method $this->getTemplateInstance()->finishElement($resource, $nodeName); } @@ -423,7 +447,7 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT * @param $uncompactedContent The uncompacted content * @return $compactedContent The compacted content */ - public function compactContent ($uncompactedContent) { + public function compactContent (string $uncompactedContent) { // Compact it ... $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent);