From 24a9617088c80727bd4b348c8592224e447b9b92 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 31 Aug 2012 13:41:18 +0200 Subject: [PATCH] Controller-Basisklasse: bei run_before/after-Hooks den Namen der Action mitgeben --- SL/Controller/Base.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index f99b1e722..acf5df593 100644 --- a/SL/Controller/Base.pm +++ b/SL/Controller/Base.pm @@ -160,10 +160,10 @@ sub _run_hooks { || ($hook->{except} && $hook->{except}->{$action}); if (ref($hook->{code}) eq 'CODE') { - $hook->{code}->($self); + $hook->{code}->($self, $action); } else { my $sub = $hook->{code}; - $self->$sub; + $self->$sub($action); } } } @@ -328,6 +328,10 @@ hooks themselves are run as instance methods. Hooks are run in the order they're added. +The hooks receive a single parameter: the name of the action that is +about to be called (for C hooks) / was called (for C +hooks). + The return value of the hooks is discarded. Hooks can be defined to run for all actions, for only specific actions -- 2.20.1