From 9f0f3edc345fea85a672927dc60d853ae8654869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Holan?= Date: Thu, 6 Dec 2018 08:15:48 +0100 Subject: [PATCH 1/2] Added $templateFile to UI\Control --- src/Application/UI/Control.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Application/UI/Control.php b/src/Application/UI/Control.php index da20357ee..247d4f49f 100644 --- a/src/Application/UI/Control.php +++ b/src/Application/UI/Control.php @@ -25,6 +25,9 @@ abstract class Control extends Component implements IRenderable /** @var ITemplateFactory */ private $templateFactory; + /** @var string|null */ + private $templateFile = null; + /** @var ITemplate */ private $template; @@ -42,6 +45,24 @@ final public function setTemplateFactory(ITemplateFactory $templateFactory) } + final public function setTemplateFile(string $templateFile = null) + { + $this->templateFile = $templateFile; + + if ($this->template !== null) { + $this->template->setFile($templateFile); + } + + return $this; + } + + + final public function getTemplateFile(): ?string + { + return $this->templateFile; + } + + final public function getTemplate(): ITemplate { if ($this->template === null) { @@ -54,7 +75,13 @@ final public function getTemplate(): ITemplate protected function createTemplate(): ITemplate { $templateFactory = $this->templateFactory ?: $this->getPresenter()->getTemplateFactory(); - return $templateFactory->createTemplate($this); + $template = $templateFactory->createTemplate($this); + + if ($this->templateFile !== null) { + $template->setFile($this->templateFile); + } + + return $template; } From 08cd2501c8d16bcb753dbcd5a745ffd11bf6cacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Holan?= Date: Mon, 10 Dec 2018 17:08:42 +0100 Subject: [PATCH 2/2] Fix coding standards --- src/Application/UI/Control.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Application/UI/Control.php b/src/Application/UI/Control.php index 247d4f49f..302ef4a87 100644 --- a/src/Application/UI/Control.php +++ b/src/Application/UI/Control.php @@ -26,7 +26,7 @@ abstract class Control extends Component implements IRenderable private $templateFactory; /** @var string|null */ - private $templateFile = null; + private $templateFile; /** @var ITemplate */ private $template; @@ -52,7 +52,6 @@ final public function setTemplateFile(string $templateFile = null) if ($this->template !== null) { $this->template->setFile($templateFile); } - return $this; }