Skip to content

Commit

Permalink
Added $templateFile to UI\Control
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom谩拧 Holan committed Dec 6, 2018
1 parent fc63a71 commit 9f0f3ed
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Application/UI/Control.php
Expand Up @@ -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;

Expand All @@ -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) {
Expand All @@ -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;
}


Expand Down

0 comments on commit 9f0f3ed

Please sign in to comment.