Bug 16111: [CHANGED] Replace link href by link in rss part
[koha.git] / Koha / Object / Mixin / AdditionalFields.pm
blob0ee9bd9143c7ee9afe703d97a80dd256ce02d7e9
1 package Koha::Object::Mixin::AdditionalFields;
3 use Modern::Perl;
4 use Koha::AdditionalFieldValues;
6 =head1 NAME
8 Koha::Object::Mixin::AdditionalFields
10 =head1 SYNOPSIS
12 package Koha::Foo;
14 use parent qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
16 sub _type { 'Foo' }
19 package main;
21 use Koha::Foo;
23 Koha::Foos->find($id)->set_additional_fields(...);
25 =head1 API
27 =head2 Public methods
29 =head3 set_additional_fields
31 $foo->set_additional_fields([
33 id => 1,
34 value => 'foo',
37 id => 2,
38 value => 'bar',
40 ]);
42 =cut
44 sub set_additional_fields {
45 my ($self, $additional_fields) = @_;
47 $self->additional_field_values->delete;
49 foreach my $additional_field (@$additional_fields) {
50 my $value = $additional_field->{value};
51 if (defined $value) {
52 my $field_value = Koha::AdditionalFieldValue->new({
53 field_id => $additional_field->{id},
54 record_id => $self->id,
55 value => $value,
56 })->store;
61 =head3 additional_field_values
63 Returns additional field values
65 my @values = $foo->additional_field_values;
67 =cut
69 sub additional_field_values {
70 my ($self) = @_;
72 my $afv_rs = $self->_result->additional_field_values;
73 return Koha::AdditionalFieldValues->_new_from_dbic( $afv_rs );
76 =head1 AUTHOR
78 Koha Development Team <http://koha-community.org/>
80 =head1 COPYRIGHT AND LICENSE
82 Copyright 2018 BibLibre
84 This file is part of Koha.
86 Koha is free software; you can redistribute it and/or modify it under the
87 terms of the GNU General Public License as published by the Free Software
88 Foundation; either version 3 of the License, or (at your option) any later
89 version.
91 Koha is distributed in the hope that it will be useful, but WITHOUT ANY
92 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
93 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
95 You should have received a copy of the GNU General Public License along
96 with Koha; if not, see <http://www.gnu.org/licenses>.
98 =cut