Revision e78e225b
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
SL/Controller/Helper/ParseFilter.pm | ||
---|---|---|
104 | 104 |
my ($key, $value) = ($flattened->[$i], $flattened->[$i+1]); |
105 | 105 |
my ($type, $op) = $key =~ m{:(.+)::(.+)}; |
106 | 106 |
|
107 |
if ($key =~ s/:multi//) { |
|
108 |
my @multi; |
|
109 |
my $orig_key = $key; |
|
110 |
for my $value (parse_line('\s+', 0, $value)) { |
|
111 |
($key, $value) = _apply_all($key, $value, qr/\b:(\w+)/, { %filters, %{ $params{filters} || {} } }); |
|
112 |
($key, $value) = _apply_all($key, $value, qr/\b::(\w+)/, { %methods, %{ $params{methods} || {} } }); |
|
113 |
($key, $value) = _dispatch_custom_filters($params{class}, $with_objects, $key, $value) if $params{class}; |
|
114 |
($key, $value) = _apply_value_filters($key, $value, $type, $op); |
|
115 |
push @multi, $key, $value; |
|
116 |
$key = $orig_key; |
|
117 |
} |
|
118 |
($key, $value) = (and => \@multi); |
|
119 |
} else { |
|
120 |
($key, $value) = _apply_all($key, $value, qr/\b:(\w+)/, { %filters, %{ $params{filters} || {} } }); |
|
121 |
($key, $value) = _apply_all($key, $value, qr/\b::(\w+)/, { %methods, %{ $params{methods} || {} } }); |
|
122 |
($key, $value) = _dispatch_custom_filters($params{class}, $with_objects, $key, $value) if $params{class}; |
|
123 |
($key, $value) = _apply_value_filters($key, $value, $type, $op); |
|
107 |
my $is_multi = $key =~ s/:multi//; |
|
108 |
my $orig_key = $key; |
|
109 |
my @value_tokens = $is_multi ? parse_line('\s+', 0, $value) : ($value); |
|
110 |
|
|
111 |
my @args; |
|
112 |
|
|
113 |
for my $value_token (@value_tokens) { |
|
114 |
$key = $orig_key; |
|
115 |
|
|
116 |
($key, $value_token) = _apply_all($key, $value_token, qr/\b:(\w+)/, { %filters, %{ $params{filters} || {} } }); |
|
117 |
($key, $value_token) = _apply_all($key, $value_token, qr/\b::(\w+)/, { %methods, %{ $params{methods} || {} } }); |
|
118 |
($key, $value_token) = _dispatch_custom_filters($params{class}, $with_objects, $key, $value_token) if $params{class}; |
|
119 |
($key, $value_token) = _apply_value_filters($key, $value_token, $type, $op); |
|
120 |
|
|
121 |
push @args, $key, $value_token; |
|
124 | 122 |
} |
125 | 123 |
|
126 |
push @result, $key, $value if defined $key; |
|
124 |
next unless defined $key; |
|
125 |
|
|
126 |
push @result, $is_multi ? (and => [ @args ]) : @args; |
|
127 | 127 |
} |
128 | 128 |
return \@result; |
129 | 129 |
} |
Auch abrufbar als: Unified diff
ParseFilter: re-factoring des Anwendens von Filtern und Methoden