Skip to content

Commit dd5b590

Browse files
solcikdg
authored andcommitted
Control, Presenter::createTemplate() added parameter $class for custom creation of the Template
1 parent a77b313 commit dd5b590

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.phpstorm.meta.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@
6464
exitPoint(\Nette\Application\UI\Presenter::sendResponse());
6565
exitPoint(\Nette\Application\UI\Presenter::sendTemplate());
6666
exitPoint(\Nette\Application\UI\Presenter::terminate());
67+
68+
override(\Nette\Application\UI\Control::createTemplate(0), map(['' => '@']));

src/Application/UI/Control.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ final public function getTemplate(): ITemplate
5151
}
5252

5353

54-
protected function createTemplate(): ITemplate
54+
/**
55+
* @param string $class
56+
*/
57+
protected function createTemplate(/*string $class = null*/): ITemplate
5558
{
59+
$class = func_num_args() ? func_get_arg(0) : $this->formatTemplateClass(); // back compatibility
5660
$templateFactory = $this->templateFactory ?: $this->getPresenter()->getTemplateFactory();
57-
return $templateFactory->createTemplate($this, $this->formatTemplateClass());
61+
return $templateFactory->createTemplate($this, $class);
5862
}
5963

6064

src/Application/UI/Presenter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,13 @@ public static function formatRenderMethod(string $view): string
551551
}
552552

553553

554-
protected function createTemplate(): ITemplate
554+
/**
555+
* @param string $class
556+
*/
557+
protected function createTemplate(/*string $class = null*/): ITemplate
555558
{
556-
return $this->getTemplateFactory()->createTemplate($this, $this->formatTemplateClass());
559+
$class = func_num_args() ? func_get_arg(0) : $this->formatTemplateClass(); // back compatibility
560+
return $this->getTemplateFactory()->createTemplate($this, $class);
557561
}
558562

559563

tests/Application/Presenter.twoDomains.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php';
1616

1717
class TestPresenter extends Application\UI\Presenter
1818
{
19-
protected function createTemplate($class = null): Application\UI\ITemplate
19+
protected function createTemplate(string $class = null): Application\UI\ITemplate
2020
{
2121
}
2222
}

0 commit comments

Comments
 (0)