Bugzilla – Attachment 148041 Details for
Bug 33161
Implement +strings for GET /items and GET /items/:item_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33161: Clarify method names
Bug-33161-Clarify-method-names.patch (text/plain), 3.28 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-03-09 22:50:51 UTC
(
hide
)
Description:
Bug 33161: Clarify method names
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-03-09 22:50:51 UTC
Size:
3.28 KB
patch
obsolete
>From ef65bd6c895017012b99101b35dcb3f7e1fbdbb9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 9 Mar 2023 13:14:04 +0000 >Subject: [PATCH] Bug 33161: Clarify method names > >The api_strings_mapping method isn't really only about api strings.. we >deal with database fields in and out.. we just happen to then use those >in to_api to map in the api. > >This patch simply renames the standard method whilst we're still early. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Item.pm | 4 ++-- > Koha/Object.pm | 24 ++++++++++++------------ > 2 files changed, 14 insertions(+), 14 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 588ea1777e0..647f703fd57 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -2058,13 +2058,13 @@ sub is_denied_renewal { > return 0; > } > >-=head3 api_strings_mapping >+=head3 strings_map > > Retrieves for each column name the unblessed authorised value. > > =cut > >-sub api_strings_mapping { >+sub strings_map { > my ( $self, $params ) = @_; > > my $columns_info = $self->_result->result_source->columns_info; >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 102d7154dbe..7f511259b1f 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -562,9 +562,9 @@ sub to_api { > my $strings = delete $params->{strings}; > > # coded values handling >- my $avs = {}; >- if ( $strings and $self->can('api_strings_mapping') ) { >- $avs = $self->api_strings_mapping($params); >+ my $string_map = {}; >+ if ( $strings and $self->can('strings_map') ) { >+ $string_map = $self->strings_map($params); > } > > # Remove forbidden attributes if required (including their coded values) >@@ -575,8 +575,8 @@ sub to_api { > } > > if ($strings) { >- foreach my $field ( keys %{$avs} ) { >- delete $avs->{$field} >+ foreach my $field ( keys %{$string_map} ) { >+ delete $string_map->{$field} > unless any { $_ eq $field } @{ $self->public_read_list }; > } > } >@@ -594,8 +594,8 @@ sub to_api { > > # key != undef > $json_object->{$mapped_column} = delete $json_object->{$column}; >- $avs->{$mapped_column} = delete $avs->{$column} >- if exists $avs->{$column}; >+ $string_map->{$mapped_column} = delete $string_map->{$column} >+ if exists $string_map->{$column}; > > } > elsif ( exists $json_object->{$column} >@@ -604,12 +604,12 @@ sub to_api { > > # key == undef > delete $json_object->{$column}; >- delete $avs->{$column}; >+ delete $string_map->{$column}; > } > } > } > >- $json_object->{_strings} = $avs >+ $json_object->{_strings} = $string_map > if $strings; > > if ($embeds) { >@@ -676,10 +676,10 @@ sub to_api_mapping { > return {}; > } > >-=head3 api_strings_mapping >+=head3 strings_map > > my $params = { is_public => 1 }; >- my $string_map = $object->api_strings_mapping($params); >+ my $string_map = $object->strings_map($params); > > Generic method that returns the string map for coded attributes. > >@@ -693,7 +693,7 @@ own mapping returned. > > =cut > >-sub api_strings_mapping { >+sub strings_map { > return {}; > } > >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33161
:
147888
|
147973
|
147977
|
147995
|
147998
|
147999
|
148010
|
148011
|
148012
|
148013
|
148014
|
148039
|
148040
|
148041
|
148042
|
148043
|
148059
|
148060
|
148061
|
148062
|
148063
|
148068
|
148075