* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate {
+ /**
+ * Template engine instance
+ */
+ private $templateInstance = NULL;
+
/**
* Protected constructor
*
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
*
* @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);
}
/**
* 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);
}
/**
* @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);
}
/**
* 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);
}
/**
* @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);
}
* 'html' by default
* @return void
*/
- public function loadHtmlTemplate ($template) {
+ public function loadHtmlTemplate (string $template) {
// Call the inner class' method
$this->getTemplateInstance()->loadHtmlTemplate($template);
}
* @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);
}
* 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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);
}
* @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);