Revision 0152cc2e
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/Helper/GetModels.pm | ||
---|---|---|
11 | 11 |
|
12 | 12 |
use Rose::Object::MakeMethods::Generic ( |
13 | 13 |
scalar => [ qw(controller model query with_objects filtered sorted paginated finalized final_params) ], |
14 |
'scalar --get_set_init' => [ qw(handlers source) ], |
|
14 |
'scalar --get_set_init' => [ qw(handlers source additional_url_params) ],
|
|
15 | 15 |
array => [ qw(plugins) ], |
16 | 16 |
); |
17 | 17 |
|
... | ... | |
113 | 113 |
|
114 | 114 |
return %{ $self->final_params } if $self->finalized; |
115 | 115 |
|
116 |
$self->register_handlers(callback => sub { shift; (@_, %{ $self->additional_url_params }) }) if %{ $self->additional_url_params }; |
|
117 |
|
|
116 | 118 |
push @{ $params{query} ||= [] }, @{ $self->query || [] }; |
117 | 119 |
push @{ $params{with_objects} ||= [] }, @{ $self->with_objects || [] }; |
118 | 120 |
|
... | ... | |
131 | 133 |
map { push @{ $handlers->{$_} }, $additional_handlers{$_} if $additional_handlers{$_} } keys %$handlers; |
132 | 134 |
} |
133 | 135 |
|
136 |
sub add_additional_url_params { |
|
137 |
my ($self, %params) = @_; |
|
138 |
|
|
139 |
$self->additional_url_params({ %{ $self->additional_url_params }, %params }); |
|
140 |
|
|
141 |
return $self; |
|
142 |
} |
|
143 |
|
|
134 | 144 |
sub get_models_url_params { |
135 | 145 |
my ($self, $sub_name_or_code) = @_; |
136 | 146 |
|
... | ... | |
190 | 200 |
$::form |
191 | 201 |
} |
192 | 202 |
|
203 |
sub init_additional_url_params { +{} } |
|
204 |
|
|
193 | 205 |
1; |
194 | 206 |
__END__ |
195 | 207 |
|
... | ... | |
254 | 266 |
The value returned by C<SUB> must be either a single hash |
255 | 267 |
reference or a hash of key/value pairs to add to the URL. |
256 | 268 |
|
269 |
=item add_additional_url_params C<%params> |
|
270 |
|
|
271 |
Sets additional parameters that will be added to each URL generated by |
|
272 |
this model (e.g. for pagination/sorting). This is just sugar for a |
|
273 |
proper call to L<get_models_url_params> with an anonymous sub adding |
|
274 |
those parameters. |
|
275 |
|
|
257 | 276 |
=item get_callback |
258 | 277 |
|
259 | 278 |
Returns a URL suitable for use as a callback parameter. It maps to the |
Auch abrufbar als: Unified diff
GetModels: Funktion zum Setzen zusätzlicher URL-Parameter