From d0e81e7bbac523be5f906410a6a6399c6347e27e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 7 Nov 2020 22:11:16 +0100 Subject: [PATCH] Continued: - added missing $templateInstance, some chaos is normal after a rewrite - added missing type-hints for primitive variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../classes/commands/class_BaseCommand.php | 54 +++++++++++++------ .../classes/resolver/class_BaseResolver.php | 8 +-- .../classes/response/class_BaseResponse.php | 5 -- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/framework/main/classes/commands/class_BaseCommand.php b/framework/main/classes/commands/class_BaseCommand.php index c7e0e9e0..8642dedf 100644 --- a/framework/main/classes/commands/class_BaseCommand.php +++ b/framework/main/classes/commands/class_BaseCommand.php @@ -9,7 +9,7 @@ use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Resolver; use Org\Mxchange\CoreFramework\Response\Responseable; - +use Org\Mxchange\CoreFramework\Template\CompileableTemplate; /** * A general (base) command * @@ -38,6 +38,11 @@ abstract class BaseCommand extends BaseFrameworkSystem { */ private $resolverInstance = NULL; + /** + * Template engine instance + */ + private $templateInstance = NULL; + /** * Protected constructor * @@ -49,20 +54,6 @@ abstract class BaseCommand extends BaseFrameworkSystem { parent::__construct($className); } - /** - * Initializes the template engine - * - * @param $templateType Type of template, e.g. 'html', 'image', 'console' ... - * @return void - */ - public final function initTemplateEngine (string $templateType) { - // Prepare a template instance - $templateInstance = ObjectFactory::createObjectByConfiguredName(sprintf('%s_template_class', $templateType)); - - // Set it here - $this->setTemplateInstance($templateInstance); - } - /** * Setter for resolver instance * @@ -82,6 +73,39 @@ abstract class BaseCommand extends BaseFrameworkSystem { return $this->resolverInstance; } + /** + * 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 + */ + public final function getTemplateInstance () { + return $this->templateInstance; + } + + /** + * Initializes the template engine + * + * @param $templateType Type of template, e.g. 'html', 'image', 'console' ... + * @return void + */ + public final function initTemplateEngine (string $templateType) { + // Prepare a template instance + $templateInstance = ObjectFactory::createObjectByConfiguredName(sprintf('%s_template_class', $templateType)); + + // Set it here + $this->setTemplateInstance($templateInstance); + } + /** * Sends a generic HTTP response with header, menu, content and footer * diff --git a/framework/main/classes/resolver/class_BaseResolver.php b/framework/main/classes/resolver/class_BaseResolver.php index 7b262c37..c92a0ab2 100644 --- a/framework/main/classes/resolver/class_BaseResolver.php +++ b/framework/main/classes/resolver/class_BaseResolver.php @@ -88,8 +88,8 @@ abstract class BaseResolver extends BaseFrameworkSystem { * @param $namespace Namespace to look in * @return void */ - protected final function setNamespace ($namespace) { - $this->namespace = (string) $namespace; + protected final function setNamespace (string $namespace) { + $this->namespace = $namespace; } /** @@ -107,8 +107,8 @@ abstract class BaseResolver extends BaseFrameworkSystem { * @param $className Name of the class * @return void */ - protected final function setClassName ($className) { - $this->className = (string) $className; + protected final function setClassName (string $className) { + $this->className = $className; } /** diff --git a/framework/main/classes/response/class_BaseResponse.php b/framework/main/classes/response/class_BaseResponse.php index ece0dbd2..a52a53bf 100644 --- a/framework/main/classes/response/class_BaseResponse.php +++ b/framework/main/classes/response/class_BaseResponse.php @@ -53,11 +53,6 @@ abstract class BaseResponse extends BaseFrameworkSystem { */ private $responseBody = ''; - /** - * Instance of the template engine - */ - private $templateInstance = NULL; - /** * Response type */ -- 2.39.5