Lines 38-47
sub register {
Link Here
|
38 |
|
38 |
|
39 |
my $patrons_rs = Koha::Patrons->new; |
39 |
my $patrons_rs = Koha::Patrons->new; |
40 |
my $patrons = $c->objects->find( $patrons_rs, $id ); |
40 |
my $patrons = $c->objects->find( $patrons_rs, $id ); |
|
|
41 |
. . . |
42 |
return $c->render({ status => 200, openapi => $patron }); |
41 |
|
43 |
|
42 |
Performs a database search using given Koha::Objects object and the $id. |
44 |
Performs a database search using given Koha::Objects object and the $id. |
43 |
|
45 |
|
44 |
Returns I<undef> if no object is found Returns the I<API representation> of |
46 |
Returns I<undef> if no object is found or the I<API representation> of |
45 |
the requested object. It passes through any embeds if specified. |
47 |
the requested object. It passes through any embeds if specified. |
46 |
|
48 |
|
47 |
=cut |
49 |
=cut |
Lines 55-81
the requested object. It passes through any embeds if specified.
Link Here
|
55 |
} |
57 |
} |
56 |
); |
58 |
); |
57 |
|
59 |
|
|
|
60 |
|
58 |
=head3 objects.find_rs |
61 |
=head3 objects.find_rs |
59 |
|
62 |
|
60 |
my $patrons_rs = Koha::Patrons->new; |
63 |
my $patrons_rs = Koha::Patrons->new; |
61 |
my $patrons = $c->objects->find_rs( $patrons_rs, $id ); |
64 |
my $patron_rs = $c->objects->find_rs( $patrons_rs, $id ); |
|
|
65 |
. . . |
66 |
return $c->render({ status => 200, openapi => $patron_rs->to_api }); |
62 |
|
67 |
|
63 |
Performs a database search using given Koha::Objects object and the $id. |
68 |
Returns the passed Koha::Objects resultset filtered to the passed $id and |
|
|
69 |
with any embeds requested by the api applied. |
64 |
|
70 |
|
65 |
Returns a new resultset for further processing. It passes through any embeds if specified. |
71 |
The resultset can then be used for further processing. |
66 |
|
72 |
|
67 |
=cut |
73 |
=cut |
68 |
|
74 |
|
69 |
$app->helper( |
75 |
$app->helper( |
70 |
'objects.find_rs' => sub { |
76 |
'objects.find_rs' => sub { |
71 |
my ( $c, $result_set, $id ) = @_; |
77 |
my ( $c, $result_set, $id ) = @_; |
72 |
|
78 |
|
73 |
my $attributes = {}; |
79 |
my $attributes = {}; |
74 |
|
80 |
|
75 |
# Look for embeds |
|
|
76 |
my $embed = $c->stash('koha.embed'); |
77 |
my $strings = $c->stash('koha.strings'); |
78 |
|
79 |
# Generate prefetches for embedded stuff |
81 |
# Generate prefetches for embedded stuff |
80 |
$c->dbic_merge_prefetch( |
82 |
$c->dbic_merge_prefetch( |
81 |
{ |
83 |
{ |
Lines 83-91
Returns a new resultset for further processing. It passes through any embeds if
Link Here
|
83 |
result_set => $result_set |
85 |
result_set => $result_set |
84 |
} |
86 |
} |
85 |
); |
87 |
); |
86 |
|
88 |
|
87 |
my $object = $result_set->find( $id, $attributes ); |
89 |
my $object = $result_set->find( $id, $attributes ); |
88 |
|
90 |
|
89 |
return $object; |
91 |
return $object; |
90 |
} |
92 |
} |
91 |
); |
93 |
); |
Lines 94-101
Returns a new resultset for further processing. It passes through any embeds if
Link Here
|
94 |
|
96 |
|
95 |
my $patrons_rs = Koha::Patrons->new; |
97 |
my $patrons_rs = Koha::Patrons->new; |
96 |
my $patrons = $c->objects->search( $patrons_rs ); |
98 |
my $patrons = $c->objects->search( $patrons_rs ); |
|
|
99 |
. . . |
100 |
return $c->render({ status => 200, openapi => $patrons }); |
97 |
|
101 |
|
98 |
Performs a database search using given Koha::Objects object and query parameters. |
102 |
Performs a database search using given Koha::Objects object with any api |
|
|
103 |
query parameters applied. |
99 |
|
104 |
|
100 |
Returns an arrayref of the hashrefs representing the resulting objects |
105 |
Returns an arrayref of the hashrefs representing the resulting objects |
101 |
for API rendering. |
106 |
for API rendering. |
Lines 108-114
shouldn't be called twice in it.
Link Here
|
108 |
$app->helper( |
113 |
$app->helper( |
109 |
'objects.search' => sub { |
114 |
'objects.search' => sub { |
110 |
my ( $c, $result_set ) = @_; |
115 |
my ( $c, $result_set ) = @_; |
111 |
|
116 |
|
112 |
return $c->objects->to_api( $c->objects->search_rs($result_set) ); |
117 |
return $c->objects->to_api( $c->objects->search_rs($result_set) ); |
113 |
} |
118 |
} |
114 |
); |
119 |
); |
Lines 116-126
shouldn't be called twice in it.
Link Here
|
116 |
=head3 objects.search_rs |
121 |
=head3 objects.search_rs |
117 |
|
122 |
|
118 |
my $patrons_rs = Koha::Patrons->new; |
123 |
my $patrons_rs = Koha::Patrons->new; |
119 |
my $filtered_patrons_rs = $c->objects->search_rs( $patrons_rs ); |
124 |
my $patrons_rs = $c->objects->search_rs( $patrons_rs ); |
120 |
|
125 |
. . . |
121 |
Performs a database search using given Koha::Objects object and query parameters. |
126 |
return $c->render({ status => 200, openapi => $patrons_rs->to_api }); |
122 |
|
127 |
|
123 |
Returns a new resultset for further processing. |
128 |
Returns the passed Koha::Objects resultset filtered as requested by the api query |
|
|
129 |
parameters and with requested embeds applied. |
124 |
|
130 |
|
125 |
Warning: this helper adds pagination headers to the calling controller, and thus |
131 |
Warning: this helper adds pagination headers to the calling controller, and thus |
126 |
shouldn't be called twice in it. |
132 |
shouldn't be called twice in it. |
Lines 138-146
shouldn't be called twice in it.
Link Here
|
138 |
my ( $filtered_params, $reserved_params, $path_params ) = |
144 |
my ( $filtered_params, $reserved_params, $path_params ) = |
139 |
$c->extract_reserved_params($args); |
145 |
$c->extract_reserved_params($args); |
140 |
|
146 |
|
141 |
# Privileged reques? |
|
|
142 |
my $is_public = $c->stash('is_public'); |
143 |
|
144 |
# Merge sorting into query attributes |
147 |
# Merge sorting into query attributes |
145 |
$c->dbic_merge_sorting( |
148 |
$c->dbic_merge_sorting( |
146 |
{ |
149 |
{ |
147 |
- |
|
|