[Koha-bugs] [Bug 19410] Add a helper function for generating object searches for the API

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Nov 27 19:52:40 CET 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410

--- Comment #37 from Kyle M Hall <kyle at bywatersolutions.com> ---
I think rather than calling _to_model in each Controller, we should move that
call to Koha::REST::Plugin::Objects, something like

diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm
index eb3f951..163e364 100644
--- a/Koha/REST/Plugin/Objects.pm
+++ b/Koha/REST/Plugin/Objects.pm
@@ -45,7 +45,7 @@ sub register {
         'objects.search' => sub {
             my ( $c, $objects_set ) = @_;

-            my $args = $c->validation->output;
+            my $args = $objects_set->_to_model( $c->validation->output );
             my $attributes = {};

and change the extract to
my ($params, $reserved_params) = $c->extract_reserved_params(
$c->validation->output );
or something like that so the above 'patch' doesn't break it.

We could add _to_model to a parent class of the modules in Koha::REST::V1 that
essentially does nothing, and then each child class could override it with any
customizations if necessary.

That would simplify the code, and allow customization easily, if it is needed.
If it isn't the class just won't have a _to_model method.

This is probably better to implement in a followup bug report. That patches
themselves appear to work great!

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list