@@ -, +, @@ --- C4/Service.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) --- a/C4/Service.pm +++ a/C4/Service.pm @@ -204,6 +204,32 @@ sub require_params { return @values; } +=head2 optional_params + + my @values = C4::Service->optional_params( @params ); + +Check that each of of the parameters specified in @params was sent in the +request, then return their values in that order. If any were not sent in +the request, undef is returned for that value. + +=cut + +sub optional_params { + my ( $class, @params ) = @_; + + my @values; + + for my $param ( @params ) { + if ( !defined( $query->param( $param ) ) ) { + push @values, undef; + } else { + push @values, $query->param( $param ); + } + } + + return @values; +} + =head2 dispatch C4::Service->dispatch( --