Revision 8e405005
Von Moritz Bunkus vor etwa 9 Jahren hinzugefügt
SL/Controller/Helper/ParseFilter.pm | ||
---|---|---|
149 | 149 |
die 'unrecognized filters' if $key =~ /:/; |
150 | 150 |
|
151 | 151 |
my @tokens = split /\./, $key; |
152 |
my $last_token = pop @tokens; |
|
153 | 152 |
my $curr_class = $class->object_class; |
154 | 153 |
|
155 |
for my $token (@tokens) { |
|
154 |
# find first token which is not a relationship |
|
155 |
my $i = 0; |
|
156 |
while ($i < $#tokens) { |
|
156 | 157 |
eval { |
157 |
$curr_class = $curr_class->meta->relationship($token)->class; |
|
158 |
1;
|
|
158 |
$curr_class = $curr_class->meta->relationship($tokens[$_])->class;
|
|
159 |
++$i;
|
|
159 | 160 |
} or do { |
160 |
require Carp; |
|
161 |
Carp::croak("Could not resolve the relationship '$token' in '$key' while building the filter request"); |
|
161 |
last; |
|
162 | 162 |
} |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
my $manager = $curr_class->meta->convention_manager->auto_manager_class_name; |
166 |
my $obj_path = join '.', @tokens; |
|
167 |
my $obj_prefix = join '.', @tokens, ''; |
|
166 |
my $obj_path = join '.', @tokens[0..$i-1]; |
|
167 |
my $obj_prefix = join '.', @tokens[0..$i-1], ''; |
|
168 |
my $key_token = $tokens[$i]; |
|
169 |
my @additional_tokens = @tokens[$i+1..$#tokens]; |
|
168 | 170 |
|
169 | 171 |
if ($manager->can('filter')) { |
170 |
($key, $value, my $obj) = $manager->filter($last_token, $value, $obj_prefix, $obj_path);
|
|
172 |
($key, $value, my $obj) = $manager->filter($key_token, $value, $obj_prefix, $obj_path, @additional_tokens);
|
|
171 | 173 |
_add_uniq($with_objects, $obj) if $obj; |
172 | 174 |
} else { |
173 | 175 |
_add_uniq($with_objects, $obj_path) if $obj_path; |
Auch abrufbar als: Unified diff
GetModels-Filtered: Unterstützung für benutzerdefinierte Variablen