@@ -116,7 +116,6 @@ abstract class Presenter extends Control implements Application\IPresenter
116
116
117
117
public function __construct ()
118
118
{
119
- $ this ->payload = new \stdClass ;
120
119
}
121
120
122
121
@@ -170,7 +169,6 @@ public function isModuleCurrent(string $module): bool
170
169
public function run (Application \Request $ request ): Application \Response
171
170
{
172
171
$ this ->request = $ request ;
173
- $ this ->payload ??= new \stdClass ;
174
172
$ this ->setParent ($ this ->getParent (), $ request ->getPresenterName ());
175
173
176
174
if (!$ this ->httpResponse ->isSent ()) {
@@ -227,7 +225,7 @@ public function run(Application\Request $request): Application\Response
227
225
$ this ->saveGlobalState ();
228
226
229
227
if ($ this ->isAjax ()) {
230
- $ this ->payload ->state = $ this ->getGlobalState ();
228
+ $ this ->getPayload () ->state = $ this ->getGlobalState ();
231
229
try {
232
230
if ($ this ->response instanceof Responses \TextResponse && $ this ->isControlInvalid ()) {
233
231
$ this ->snippetMode = true ;
@@ -570,7 +568,7 @@ public function formatTemplateClass(): ?string
570
568
571
569
final public function getPayload (): \stdClass
572
570
{
573
- return $ this ->payload ;
571
+ return $ this ->payload ??= new \ stdClass ;
574
572
}
575
573
576
574
@@ -594,7 +592,7 @@ public function isAjax(): bool
594
592
*/
595
593
public function sendPayload (): void
596
594
{
597
- $ this ->sendResponse (new Responses \JsonResponse ($ this ->payload ));
595
+ $ this ->sendResponse (new Responses \JsonResponse ($ this ->getPayload () ));
598
596
}
599
597
600
598
@@ -663,7 +661,7 @@ public function forward(string|Nette\Application\Request $destination, $args = [
663
661
public function redirectUrl (string $ url , ?int $ httpCode = null ): void
664
662
{
665
663
if ($ this ->isAjax ()) {
666
- $ this ->payload ->redirect = $ url ;
664
+ $ this ->getPayload () ->redirect = $ url ;
667
665
$ this ->sendPayload ();
668
666
669
667
} elseif (!$ httpCode ) {
0 commit comments