@@ -222,33 +222,36 @@ public function run(Application\Request $request)
222222 }
223223
224224 } catch (Application \AbortException $ e ) {
225- // continue with shutting down
226- if ($ this ->isAjax ()) {
227- try {
228- $ hasPayload = (array ) $ this ->payload ;
229- 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- } elseif (!$ this ->response && $ hasPayload ) { // back compatibility for use terminate() instead of sendPayload()
235- trigger_error ('Use $presenter->sendPayload() instead of terminate() to send payload. ' );
236- $ this ->sendPayload ();
237- }
238- } catch (Application \AbortException $ e ) {
239- }
240- }
225+ }
241226
242- if ($ this ->hasFlashSession ()) {
243- $ this ->getFlashSession ()->setExpiration ($ this ->response instanceof Responses \RedirectResponse ? '+ 30 seconds ' : '+ 3 seconds ' );
227+ if ($ this ->isAjax ()) {
228+ try {
229+ $ hasPayload = (array ) $ this ->payload ;
230+ unset($ hasPayload ['state ' ]);
231+ if ($ this ->response instanceof Responses \TextResponse && $ this ->isControlInvalid ()) {
232+ $ this ->snippetMode = TRUE ;
233+ $ this ->response ->send ($ this ->httpRequest , $ this ->httpResponse );
234+ $ this ->sendPayload ();
235+ } elseif (!$ this ->response && $ hasPayload ) { // back compatibility for use terminate() instead of sendPayload()
236+ trigger_error ('Use $presenter->sendPayload() instead of terminate() to send payload. ' );
237+ $ this ->sendPayload ();
238+ }
239+ } catch (Application \AbortException $ e ) {
244240 }
241+ }
245242
246- // SHUTDOWN
247- $ this ->onShutdown ( $ this , $ this ->response );
248- $ this -> shutdown ( $ this -> response );
243+ if ( $ this -> hasFlashSession ()) {
244+ $ this ->getFlashSession ()-> setExpiration ( $ this ->response instanceof Responses \RedirectResponse ? ' + 30 seconds ' : ' + 3 seconds ' );
245+ }
249246
250- return $ this ->response ;
247+ if (!$ this ->response ) {
248+ $ this ->response = new Responses \VoidResponse ;
251249 }
250+
251+ $ this ->onShutdown ($ this , $ this ->response );
252+ $ this ->shutdown ($ this ->response );
253+
254+ return $ this ->response ;
252255 }
253256
254257
0 commit comments