Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 33d5d38a

Von Sven Schöling vor mehr als 11 Jahren hinzugefügt

  • ID 33d5d38a2873a25f1e9c2c37a907644fdd33f026
  • Vorgänger d70e6870
  • Nachfolger 8814f4c6

registered_handlers pro Klasse speichern.

Ansonsten kriegen sich mehrere Controller unter fcgi in die Haare.

Unterschiede anzeigen:

SL/Controller/Helper/GetModels.pm
7 7

  
8 8
use constant PRIV => '__getmodelshelperpriv';
9 9

  
10
my %registered_handlers = ( callback => [], get_models => [] );
10
my $registered_handlers = {};
11 11

  
12 12
sub register_get_models_handlers {
13 13
  my ($class, %additional_handlers) = @_;
......
18 18

  
19 19
  $class->run_before(sub { $_[0]->{PRIV()} = { current_action => $_[1] }; }, %hook_params);
20 20

  
21
  map { push @{ $registered_handlers{$_} }, $additional_handlers{$_} if $additional_handlers{$_} } keys %registered_handlers;
21
  my $handlers    = _registered_handlers($class);
22
  map { push @{ $handlers->{$_} }, $additional_handlers{$_} if $additional_handlers{$_} } keys %$handlers;
22 23
}
23 24

  
24 25
sub get_models_url_params {
......
34 35
    );
35 36
  };
36 37

  
37
  push @{ $registered_handlers{callback} }, $callback;
38
  push @{ _registered_handlers($class)->{callback} }, $callback;
38 39
}
39 40

  
40 41
sub get_callback {
......
62 63
sub _run_handlers {
63 64
  my ($self, $handler_type, %params) = @_;
64 65

  
65
  foreach my $sub (@{ $registered_handlers{$handler_type} }) {
66
  foreach my $sub (@{ _registered_handlers(ref $self)->{$handler_type} }) {
66 67
    if (ref $sub eq 'CODE') {
67 68
      %params = $sub->($self, %params);
68 69
    } elsif ($self->can($sub)) {
......
75 76
  return %params;
76 77
}
77 78

  
79
sub _registered_handlers {
80
  $registered_handlers->{$_[0]} //= { callback => [], get_models => [] }
81
}
82

  
78 83
1;
79 84
__END__
80 85

  

Auch abrufbar als: Unified diff