From a8409b4ec4efb7863e7fe5179faf87c0f8595113 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Fri, 9 Oct 2020 10:20:33 -0300 Subject: [PATCH] Bug 26636: Add objects.find helper This patch adds the objects.find helper. Much like objects.search, it returns the to_api method with embedded children and expanded authorised values. This patch will be implemented in bug 8179, so please test there --- Koha/REST/Plugin/Objects.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 7c9ef75555..a8d200d0cc 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -44,6 +44,18 @@ for API rendering. sub register { my ( $self, $app ) = @_; + $app->helper( + 'objects.find' => sub { + my ( $c, $result_set, $id ) = @_; + + # Look for embeds + my $embed = $c->stash('koha.embed'); + my $object = $result_set->find( $id ); + + return $object->to_api({ embed => $embed, av_expand => $c->req->headers->header('x-koha-av') }); + } + ); + $app->helper( 'objects.search' => sub { my ( $c, $result_set ) = @_; -- 2.25.0