|
7 | 7 |
|
8 | 8 | namespace Nette\Application\UI;
|
9 | 9 |
|
10 |
| -use Nette, |
11 |
| - Nette\Application, |
12 |
| - Nette\Application\Responses, |
13 |
| - Nette\Http; |
| 10 | +use Nette; |
| 11 | +use Nette\Application; |
| 12 | +use Nette\Application\Responses; |
| 13 | +use Nette\Http; |
14 | 14 |
|
15 | 15 |
|
16 | 16 | /**
|
@@ -48,7 +48,7 @@ abstract class Presenter extends Control implements Application\IPresenter
|
48 | 48 | /** @var int */
|
49 | 49 | public $invalidLinkMode;
|
50 | 50 |
|
51 |
| - /** @var callable[] function(Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */ |
| 51 | + /** @var callable[] function (Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */ |
52 | 52 | public $onShutdown;
|
53 | 53 |
|
54 | 54 | /** @var Nette\Application\Request */
|
@@ -225,17 +225,20 @@ public function run(Application\Request $request)
|
225 | 225 |
|
226 | 226 | } catch (Application\AbortException $e) {
|
227 | 227 | // continue with shutting down
|
228 |
| - if ($this->isAjax()) try { |
229 |
| - $hasPayload = (array) $this->payload; unset($hasPayload['state']); |
230 |
| - if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) { |
231 |
| - $this->snippetMode = TRUE; |
232 |
| - $this->response->send($this->httpRequest, $this->httpResponse); |
233 |
| - $this->sendPayload(); |
234 |
| - |
235 |
| - } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() |
| 228 | + if ($this->isAjax()) { |
| 229 | + try { |
| 230 | + $hasPayload = (array) $this->payload; |
| 231 | + unset($hasPayload['state']); |
| 232 | + if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) { |
| 233 | + $this->snippetMode = TRUE; |
| 234 | + $this->response->send($this->httpRequest, $this->httpResponse); |
| 235 | + $this->sendPayload(); |
| 236 | + } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() |
236 | 237 | $this->sendPayload();
|
| 238 | + } |
| 239 | + } catch (Application\AbortException $e) { |
237 | 240 | }
|
238 |
| - } catch (Application\AbortException $e) { } |
| 241 | + } |
239 | 242 |
|
240 | 243 | if ($this->hasFlashSession()) {
|
241 | 244 | $this->getFlashSession()->setExpiration($this->response instanceof Responses\RedirectResponse ? '+ 30 seconds' : '+ 3 seconds');
|
@@ -314,7 +317,8 @@ public function processSignal()
|
314 | 317 |
|
315 | 318 | try {
|
316 | 319 | $component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE);
|
317 |
| - } catch (Nette\InvalidArgumentException $e) {} |
| 320 | + } catch (Nette\InvalidArgumentException $e) { |
| 321 | + } |
318 | 322 |
|
319 | 323 | if (isset($e) || $component === NULL) {
|
320 | 324 | throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.", NULL, isset($e) ? $e : NULL);
|
@@ -602,7 +606,7 @@ public function sendPayload()
|
602 | 606 |
|
603 | 607 | /**
|
604 | 608 | * Sends JSON data to the output.
|
605 |
| - * @param mixed $data |
| 609 | + * @param mixed |
606 | 610 | * @return void
|
607 | 611 | * @throws Nette\Application\AbortException
|
608 | 612 | */
|
@@ -735,7 +739,8 @@ public function canonicalize()
|
735 | 739 | if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
|
736 | 740 | try {
|
737 | 741 | $url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX');
|
738 |
| - } catch (InvalidLinkException $e) {} |
| 742 | + } catch (InvalidLinkException $e) { |
| 743 | + } |
739 | 744 | if (isset($url) && !$this->httpRequest->getUrl()->isEqual($url)) {
|
740 | 745 | $this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY));
|
741 | 746 | }
|
@@ -806,21 +811,21 @@ protected function createRequest($component, $destination, array $args, $mode)
|
806 | 811 | }
|
807 | 812 |
|
808 | 813 | // 4) signal or empty
|
809 |
| - if (!$component instanceof Presenter || substr($destination, -1) === '!') { |
| 814 | + if (!$component instanceof self || substr($destination, -1) === '!') { |
810 | 815 | $signal = rtrim($destination, '!');
|
811 | 816 | $a = strrpos($signal, ':');
|
812 | 817 | if ($a !== FALSE) {
|
813 | 818 | $component = $component->getComponent(strtr(substr($signal, 0, $a), ':', '-'));
|
814 | 819 | $signal = (string) substr($signal, $a + 1);
|
815 | 820 | }
|
816 | 821 | if ($signal == NULL) { // intentionally ==
|
817 |
| - throw new InvalidLinkException("Signal must be non-empty string."); |
| 822 | + throw new InvalidLinkException('Signal must be non-empty string.'); |
818 | 823 | }
|
819 | 824 | $destination = 'this';
|
820 | 825 | }
|
821 | 826 |
|
822 | 827 | if ($destination == NULL) { // intentionally ==
|
823 |
| - throw new InvalidLinkException("Destination must be non-empty string."); |
| 828 | + throw new InvalidLinkException('Destination must be non-empty string.'); |
824 | 829 | }
|
825 | 830 |
|
826 | 831 | // 5) presenter: action
|
@@ -1314,7 +1319,7 @@ public function injectPrimary(Nette\DI\Container $context = NULL, Application\IP
|
1314 | 1319 | Http\IRequest $httpRequest, Http\IResponse $httpResponse, Http\Session $session = NULL, Nette\Security\User $user = NULL, ITemplateFactory $templateFactory = NULL)
|
1315 | 1320 | {
|
1316 | 1321 | if ($this->presenterFactory !== NULL) {
|
1317 |
| - throw new Nette\InvalidStateException("Method " . __METHOD__ . " is intended for initialization and should not be called more than once."); |
| 1322 | + throw new Nette\InvalidStateException('Method ' . __METHOD__ . ' is intended for initialization and should not be called more than once.'); |
1318 | 1323 | }
|
1319 | 1324 |
|
1320 | 1325 | $this->context = $context;
|
@@ -1368,7 +1373,7 @@ public function getSession($namespace = NULL)
|
1368 | 1373 | {
|
1369 | 1374 | if (!$this->session) {
|
1370 | 1375 | throw new Nette\InvalidStateException('Service Session has not been set.');
|
1371 |
| - } |
| 1376 | + } |
1372 | 1377 | return $namespace === NULL ? $this->session : $this->session->getSection($namespace);
|
1373 | 1378 | }
|
1374 | 1379 |
|
|
0 commit comments