Bug 23893: Remove Overloaded method from Koha::Patron
That way we are dealing with any date fields for any Koha::Object Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
8d9b93b7bc
commit
4104f782d8
2 changed files with 10 additions and 30 deletions
|
@ -491,14 +491,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;
|
||||
|
|
|
@ -1569,31 +1569,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
|
||||
|
|
Loading…
Reference in a new issue