From: Roland Häder Date: Sat, 7 Nov 2020 21:11:16 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d0e81e7bbac523be5f906410a6a6399c6347e27e;p=core.git Continued: - added missing $templateInstance, some chaos is normal after a rewrite - added missing type-hints for primitive variables Signed-off-by: Roland Häder --- 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 */