View | Details | Raw Unified | Return to bug 33161
Collapse All | Expand All

(-)a/Koha/Item.pm (-2 / +2 lines)
Lines 2058-2070 sub is_denied_renewal { Link Here
2058
    return 0;
2058
    return 0;
2059
}
2059
}
2060
2060
2061
=head3 api_strings_mapping
2061
=head3 strings_map
2062
2062
2063
Retrieves for each column name the unblessed authorised value.
2063
Retrieves for each column name the unblessed authorised value.
2064
2064
2065
=cut
2065
=cut
2066
2066
2067
sub api_strings_mapping {
2067
sub strings_map {
2068
    my ( $self, $params ) = @_;
2068
    my ( $self, $params ) = @_;
2069
2069
2070
    my $columns_info  = $self->_result->result_source->columns_info;
2070
    my $columns_info  = $self->_result->result_source->columns_info;
(-)a/Koha/Object.pm (-13 / +12 lines)
Lines 562-570 sub to_api { Link Here
562
    my $strings = delete $params->{strings};
562
    my $strings = delete $params->{strings};
563
563
564
    # coded values handling
564
    # coded values handling
565
    my $avs = {};
565
    my $string_map = {};
566
    if ( $strings and $self->can('api_strings_mapping') ) {
566
    if ( $strings and $self->can('strings_map') ) {
567
        $avs = $self->api_strings_mapping($params);
567
        $string_map = $self->strings_map($params);
568
    }
568
    }
569
569
570
    # Remove forbidden attributes if required (including their coded values)
570
    # Remove forbidden attributes if required (including their coded values)
Lines 575-582 sub to_api { Link Here
575
        }
575
        }
576
576
577
        if ($strings) {
577
        if ($strings) {
578
            foreach my $field ( keys %{$avs} ) {
578
            foreach my $field ( keys %{$string_map} ) {
579
                delete $avs->{$field}
579
                delete $string_map->{$field}
580
                  unless any { $_ eq $field } @{ $self->public_read_list };
580
                  unless any { $_ eq $field } @{ $self->public_read_list };
581
            }
581
            }
582
        }
582
        }
Lines 594-601 sub to_api { Link Here
594
594
595
                # key != undef
595
                # key != undef
596
                $json_object->{$mapped_column} = delete $json_object->{$column};
596
                $json_object->{$mapped_column} = delete $json_object->{$column};
597
                $avs->{$mapped_column}         = delete $avs->{$column}
597
                $string_map->{$mapped_column}  = delete $string_map->{$column}
598
                  if exists $avs->{$column};
598
                  if exists $string_map->{$column};
599
599
600
            }
600
            }
601
            elsif ( exists $json_object->{$column}
601
            elsif ( exists $json_object->{$column}
Lines 604-615 sub to_api { Link Here
604
604
605
                # key == undef
605
                # key == undef
606
                delete $json_object->{$column};
606
                delete $json_object->{$column};
607
                delete $avs->{$column};
607
                delete $string_map->{$column};
608
            }
608
            }
609
        }
609
        }
610
    }
610
    }
611
611
612
    $json_object->{_strings} = $avs
612
    $json_object->{_strings} = $string_map
613
      if $strings;
613
      if $strings;
614
614
615
    if ($embeds) {
615
    if ($embeds) {
Lines 676-685 sub to_api_mapping { Link Here
676
    return {};
676
    return {};
677
}
677
}
678
678
679
=head3 api_strings_mapping
679
=head3 strings_map
680
680
681
    my $params = { is_public => 1 };
681
    my $params = { is_public => 1 };
682
    my $string_map = $object->api_strings_mapping($params);
682
    my $string_map = $object->strings_map($params);
683
683
684
Generic method that returns the string map for coded attributes.
684
Generic method that returns the string map for coded attributes.
685
685
Lines 693-699 own mapping returned. Link Here
693
693
694
=cut
694
=cut
695
695
696
sub api_strings_mapping {
696
sub strings_map {
697
    return {};
697
    return {};
698
}
698
}
699
699
700
- 

Return to bug 33161