Skip to content

Commit 9f0f3ed

Browse files
author
Tomáš Holan
committed
Added $templateFile to UI\Control
1 parent fc63a71 commit 9f0f3ed

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/Application/UI/Control.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ abstract class Control extends Component implements IRenderable
2525
/** @var ITemplateFactory */
2626
private $templateFactory;
2727

28+
/** @var string|null */
29+
private $templateFile = null;
30+
2831
/** @var ITemplate */
2932
private $template;
3033

@@ -42,6 +45,24 @@ final public function setTemplateFactory(ITemplateFactory $templateFactory)
4245
}
4346

4447

48+
final public function setTemplateFile(string $templateFile = null)
49+
{
50+
$this->templateFile = $templateFile;
51+
52+
if ($this->template !== null) {
53+
$this->template->setFile($templateFile);
54+
}
55+
56+
return $this;
57+
}
58+
59+
60+
final public function getTemplateFile(): ?string
61+
{
62+
return $this->templateFile;
63+
}
64+
65+
4566
final public function getTemplate(): ITemplate
4667
{
4768
if ($this->template === null) {
@@ -54,7 +75,13 @@ final public function getTemplate(): ITemplate
5475
protected function createTemplate(): ITemplate
5576
{
5677
$templateFactory = $this->templateFactory ?: $this->getPresenter()->getTemplateFactory();
57-
return $templateFactory->createTemplate($this);
78+
$template = $templateFactory->createTemplate($this);
79+
80+
if ($this->templateFile !== null) {
81+
$template->setFile($this->templateFile);
82+
}
83+
84+
return $template;
5885
}
5986

6087

0 commit comments

Comments
 (0)