From 425bb2f20bc7df9ea0a924c2ad16fab9a5f0a0ae Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 2 Mar 2023 16:41:31 +0000 Subject: [PATCH] Bug 33080: (follow-up) Minor cleanups Whilst reviewing I spotted a few calls to the stash that were no longer required and errors in the POD for the new/updated methods This patch adds fixes for those minor issues. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/REST/Plugin/Objects.pm | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 496b7cb886..462fdf97da 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -38,10 +38,12 @@ sub register { my $patrons_rs = Koha::Patrons->new; my $patrons = $c->objects->find( $patrons_rs, $id ); + . . . + return $c->render({ status => 200, openapi => $patron }); Performs a database search using given Koha::Objects object and the $id. -Returns I if no object is found Returns the I of +Returns I if no object is found or the I of the requested object. It passes through any embeds if specified. =cut @@ -55,14 +57,18 @@ the requested object. It passes through any embeds if specified. } ); + =head3 objects.find_rs my $patrons_rs = Koha::Patrons->new; - my $patrons = $c->objects->find_rs( $patrons_rs, $id ); + my $patron_rs = $c->objects->find_rs( $patrons_rs, $id ); + . . . + return $c->render({ status => 200, openapi => $patron_rs->to_api }); -Performs a database search using given Koha::Objects object and the $id. +Returns the passed Koha::Objects resultset filtered to the passed $id and +with any embeds requested by the api applied. -Returns a new resultset for further processing. It passes through any embeds if specified. +The resultset can then be used for further processing. =cut @@ -72,10 +78,6 @@ Returns a new resultset for further processing. It passes through any embeds if my $attributes = {}; - # Look for embeds - my $embed = $c->stash('koha.embed'); - my $strings = $c->stash('koha.strings'); - # Generate prefetches for embedded stuff $c->dbic_merge_prefetch( { @@ -94,8 +96,11 @@ Returns a new resultset for further processing. It passes through any embeds if my $patrons_rs = Koha::Patrons->new; my $patrons = $c->objects->search( $patrons_rs ); + . . . + return $c->render({ status => 200, openapi => $patrons }); -Performs a database search using given Koha::Objects object and query parameters. +Performs a database search using given Koha::Objects object with any api +query parameters applied. Returns an arrayref of the hashrefs representing the resulting objects for API rendering. @@ -116,11 +121,12 @@ shouldn't be called twice in it. =head3 objects.search_rs my $patrons_rs = Koha::Patrons->new; - my $filtered_patrons_rs = $c->objects->search_rs( $patrons_rs ); + my $patrons_rs = $c->objects->search_rs( $patrons_rs ); + . . . + return $c->render({ status => 200, openapi => $patrons_rs->to_api }); -Performs a database search using given Koha::Objects object and query parameters. - -Returns a new resultset for further processing. +Returns the passed Koha::Objects resultset filtered as requested by the api query +parameters and with requested embeds applied. Warning: this helper adds pagination headers to the calling controller, and thus shouldn't be called twice in it. @@ -138,9 +144,6 @@ shouldn't be called twice in it. my ( $filtered_params, $reserved_params, $path_params ) = $c->extract_reserved_params($args); - # Privileged reques? - my $is_public = $c->stash('is_public'); - # Merge sorting into query attributes $c->dbic_merge_sorting( { -- 2.39.2