@@ -48,7 +48,7 @@ abstract class Presenter extends Control implements Application\IPresenter
4848 /** @var int */
4949 public $ invalidLinkMode ;
5050
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 */
5252 public $ onShutdown ;
5353
5454 /** @var Nette\Application\Request */
@@ -225,17 +225,20 @@ public function run(Application\Request $request)
225225
226226 } catch (Application \AbortException $ e ) {
227227 // 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()
236237 $ this ->sendPayload ();
238+ }
239+ } catch (Application \AbortException $ e ) {
237240 }
238- } catch ( Application \ AbortException $ e ) { }
241+ }
239242
240243 if ($ this ->hasFlashSession ()) {
241244 $ this ->getFlashSession ()->setExpiration ($ this ->response instanceof Responses \RedirectResponse ? '+ 30 seconds ' : '+ 3 seconds ' );
@@ -314,7 +317,8 @@ public function processSignal()
314317
315318 try {
316319 $ component = $ this ->signalReceiver === '' ? $ this : $ this ->getComponent ($ this ->signalReceiver , FALSE );
317- } catch (Nette \InvalidArgumentException $ e ) {}
320+ } catch (Nette \InvalidArgumentException $ e ) {
321+ }
318322
319323 if (isset ($ e ) || $ component === NULL ) {
320324 throw new BadSignalException ("The signal receiver component ' $ this ->signalReceiver ' is not found. " , NULL , isset ($ e ) ? $ e : NULL );
@@ -602,7 +606,7 @@ public function sendPayload()
602606
603607 /**
604608 * Sends JSON data to the output.
605- * @param mixed $data
609+ * @param mixed
606610 * @return void
607611 * @throws Nette\Application\AbortException
608612 */
@@ -735,7 +739,8 @@ public function canonicalize()
735739 if (!$ this ->isAjax () && ($ this ->request ->isMethod ('get ' ) || $ this ->request ->isMethod ('head ' ))) {
736740 try {
737741 $ url = $ this ->createRequest ($ this , $ this ->action , $ this ->getGlobalState () + $ this ->request ->getParameters (), 'redirectX ' );
738- } catch (InvalidLinkException $ e ) {}
742+ } catch (InvalidLinkException $ e ) {
743+ }
739744 if (isset ($ url ) && !$ this ->httpRequest ->getUrl ()->isEqual ($ url )) {
740745 $ this ->sendResponse (new Responses \RedirectResponse ($ url , Http \IResponse::S301_MOVED_PERMANENTLY ));
741746 }
@@ -806,21 +811,21 @@ protected function createRequest($component, $destination, array $args, $mode)
806811 }
807812
808813 // 4) signal or empty
809- if (!$ component instanceof Presenter || substr ($ destination , -1 ) === '! ' ) {
814+ if (!$ component instanceof self || substr ($ destination , -1 ) === '! ' ) {
810815 $ signal = rtrim ($ destination , '! ' );
811816 $ a = strrpos ($ signal , ': ' );
812817 if ($ a !== FALSE ) {
813818 $ component = $ component ->getComponent (strtr (substr ($ signal , 0 , $ a ), ': ' , '- ' ));
814819 $ signal = (string ) substr ($ signal , $ a + 1 );
815820 }
816821 if ($ signal == NULL ) { // intentionally ==
817- throw new InvalidLinkException (" Signal must be non-empty string. " );
822+ throw new InvalidLinkException (' Signal must be non-empty string. ' );
818823 }
819824 $ destination = 'this ' ;
820825 }
821826
822827 if ($ destination == NULL ) { // intentionally ==
823- throw new InvalidLinkException (" Destination must be non-empty string. " );
828+ throw new InvalidLinkException (' Destination must be non-empty string. ' );
824829 }
825830
826831 // 5) presenter: action
@@ -1314,7 +1319,7 @@ public function injectPrimary(Nette\DI\Container $context = NULL, Application\IP
13141319 Http \IRequest $ httpRequest , Http \IResponse $ httpResponse , Http \Session $ session = NULL , Nette \Security \User $ user = NULL , ITemplateFactory $ templateFactory = NULL )
13151320 {
13161321 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. ' );
13181323 }
13191324
13201325 $ this ->context = $ context ;
@@ -1368,7 +1373,7 @@ public function getSession($namespace = NULL)
13681373 {
13691374 if (!$ this ->session ) {
13701375 throw new Nette \InvalidStateException ('Service Session has not been set. ' );
1371- }
1376+ }
13721377 return $ namespace === NULL ? $ this ->session : $ this ->session ->getSection ($ namespace );
13731378 }
13741379
0 commit comments