Browse Source

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.

Sponsored-by: Virginia Polytechnic Institute and State University

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Agustin Moyano 1 year ago
committed by Jonathan Druart
parent
commit
329d09abb6
  1. 22
      Koha/REST/Plugin/Objects.pm

22
Koha/REST/Plugin/Objects.pm

@ -44,6 +44,28 @@ for API rendering.
sub register {
my ( $self, $app ) = @_;
$app->helper(
'objects.find' => sub {
my ( $c, $result_set, $id ) = @_;
my $attributes = {};
# Look for embeds
my $embed = $c->stash('koha.embed');
# Generate prefetches for embedded stuff
$c->dbic_merge_prefetch(
{
attributes => $attributes,
result_set => $result_set
}
);
my $object = $result_set->find( $id, $attributes );
return $object->to_api({ embed => $embed });
}
);
$app->helper(
'objects.search' => sub {
my ( $c, $result_set ) = @_;

Loading…
Cancel
Save