From aa7f51db81934e47ff7bac0a15cef97572d4c6f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 11 Jan 2011 15:37:17 +0100 Subject: [PATCH] =?utf8?q?Kategorie=20bei=20Flash=20pr=C3=BCfen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Helper/Flash.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SL/Helper/Flash.pm b/SL/Helper/Flash.pm index 78a94e34f..f55366c17 100644 --- a/SL/Helper/Flash.pm +++ b/SL/Helper/Flash.pm @@ -7,6 +7,11 @@ our @ISA = qw(Exporter); our @EXPORT = qw(flash flash_later); our @EXPORT_OK = qw(render_flash); +my %valid_categories = ( + map({$_ => 'info'} qw(information message)), + map({$_ => $_} qw(info error warning)), +); + # # public functions # @@ -29,8 +34,7 @@ sub render_flash { sub _store_flash { my $store = shift || { }; - my $category = shift; - $category = 'info' if $category eq 'information'; + my $category = _check_category(+shift); $store ||= { }; $store->{ $category } ||= [ ]; @@ -39,6 +43,12 @@ sub _store_flash { return $store; } +sub _check_category { + my ($c) = @_; + return $valid_categories{$c} + || die 'invalid category for flash'; +} + 1; __END__ -- 2.20.1