Bugzilla – Attachment 96665 Details for
Bug 23893
Add ->new_from_api and ->set_from_api methods to Koha::Object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23893: Remove Overloaded method from Koha::Patron
Bug-23893-Remove-Overloaded-method-from-KohaPatron.patch (text/plain), 2.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-12-27 18:29:05 UTC
(
hide
)
Description:
Bug 23893: Remove Overloaded method from Koha::Patron
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-12-27 18:29:05 UTC
Size:
2.27 KB
patch
obsolete
>From 8a48d396a150b37da5d6c9ef5ff2af39c6b0d7f6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 27 Dec 2019 17:03:16 +0100 >Subject: [PATCH] Bug 23893: Remove Overloaded method from Koha::Patron > >That way we are dealing with any date fields for any Koha::Object >--- > Koha/Object.pm | 15 ++++++++++----- > Koha/Patron.pm | 25 ------------------------- > 2 files changed, 10 insertions(+), 30 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 00ea8789eb..d31ae16c81 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -490,14 +490,19 @@ sub attributes_from_api { > my $from_api_mapping = $self->from_api_mapping; > > my $params; >+ my $columns_info = $self->_result->result_source->columns_info; > > while (my ($key, $value) = each %{ $from_api_params } ) { >- if ( exists $from_api_mapping->{$key} ) { >- $params->{$from_api_mapping->{$key}} = $value; >- } >- else { >- $params->{$key} = $value; >+ my $koha_field_name = >+ exists $from_api_mapping->{$key} >+ ? $from_api_mapping->{$key} >+ : $key; >+ >+ if ( _date_or_datetime_column_type( $columns_info->{$koha_field_name}->{data_type} ) ) { >+ $value = dt_from_string($value, 'rfc3339'); > } >+ >+ $params->{$koha_field_name} = $value; > } > > return $params; >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index e57ea64b7f..2de2965e7f 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1566,31 +1566,6 @@ sub to_api { > return $json_patron; > } > >-=head3 attributes_from_api >- >- my $attrs = $patron->attributes_from_api( $attrs ); >- >-Overloaded method that implement specific data transformations after >-calling the original Koha::Object->attributes_from_api method. >- >-=cut >- >-sub attributes_from_api { >- my ( $self, $attrs ) = @_; >- >- $attrs = $self->SUPER::attributes_from_api( $attrs ); >- >- if ( exists $attrs->{lastseen} ) { >- $attrs->{lastseen} = dt_from_string($attrs->{lastseen}, 'rfc3339'); >- } >- >- if ( exists $attrs->{updated_on} ) { >- $attrs->{updated_on} = dt_from_string($attrs->{updated_on}, 'rfc3339'); >- } >- >- return $attrs; >-} >- > =head3 to_api_mapping > > This method returns the mapping for representing a Koha::Patron object >-- >2.24.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 23893
:
95276
|
95277
|
95278
|
95311
|
95312
|
95313
|
95314
|
95315
|
96126
|
96127
|
96128
|
96129
|
96130
|
96652
|
96655
|
96656
|
96657
|
96658
|
96659
|
96660
|
96661
|
96662
|
96665
|
96666
|
96920
|
96921
|
96922
|
96923
|
96924
|
96925
|
96926
|
96927
|
96928
|
96929
|
96930
|
96931
|
96932
|
96933
|
96934
|
96935
|
96936
|
96937
|
97391