X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FBase.pm;h=1188ffe8bb38d3753b62efc176689031e3bf4ed7;hb=0499c65ed3ba3c3ac87b5aab9a60c3cc33be0796;hp=f99b1e722b0e5174e0ba469a8ddec3816a2e157b;hpb=469ca9fc3cac624073270fc3217766dbb7aba253;p=kivitendo-erp.git diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index f99b1e722..1188ffe8b 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); } } } @@ -204,7 +204,9 @@ sub _run_action { } sub _controller_name { - return (split(/::/, ref($_[0])))[-1]; + my $class = ref($_[0]) || $_[0]; + $class =~ s/^SL::Controller:://; + return $class; } sub _dispatch { @@ -328,6 +330,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