From abd4a0b007159d46da41dc6ed832acc3e85c9744 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 13 Feb 2012 17:09:21 +0100 Subject: [PATCH] delay_flash_on_redirect Magie im Basecontroller. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Wenn von einem Controller explizit überladen, wird der normale Föash vor einem redirect_to automatisch upgegradet in ein flash_later. Conflicts: SL/Controller/Base.pm --- SL/Controller/Base.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index 6d9434742..285bfcee4 100644 --- a/SL/Controller/Base.pm +++ b/SL/Controller/Base.pm @@ -30,6 +30,11 @@ sub redirect_to { my $self = shift; my $url = $self->url_for(@_); + if ($self->delay_flash_on_redirect) { + require SL::Helper::Flash; + SL::Helper::Flash::delay_flash(); + } + print $::request->{cgi}->redirect($url); } @@ -152,6 +157,14 @@ sub _run_hooks { } } +# +# behaviour. override these +# + +sub delay_flash_on_redirect { + 0; +} + # # private functions -- for use in Base only # @@ -482,6 +495,12 @@ action. The hook's return values are discarded. +=item delay_flash_on_redirect + +May be overridden by a controller. If this method returns true, redirect_to +will delay all flash messages for the current request. Defaults to false for +compatibility reasons. + =back =head2 PRIVATE FUNCTIONS -- 2.20.1