Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/Application/UI/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ abstract class Control extends Component implements IRenderable
/** @var ITemplateFactory */
private $templateFactory;

/** @var string|null */
private $templateFile;

/** @var ITemplate */
private $template;

Expand All @@ -42,6 +45,23 @@ 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) {
Expand All @@ -54,7 +74,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;
}


Expand Down