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

(-)a/Koha/Biblio.pm (-1 / +66 lines)
Lines 88-93 sub metadata { Link Here
88
    return Koha::Biblio::Metadata->_new_from_dbic($metadata);
88
    return Koha::Biblio::Metadata->_new_from_dbic($metadata);
89
}
89
}
90
90
91
=head3 metadata_record
92
93
    my $record = $biblio->metadata_record(
94
        {
95
            [ embed_items => 1|0,
96
              opac        => 1|0,
97
              patron      => $patron,
98
              expand_coded_fields => 1|0 ]
99
        }
100
    );
101
102
Returns the metadata serialized as appropriate for the metadata object
103
type. Currently only I<MARC::Record> objects are returned.
104
105
=cut
106
107
sub metadata_record {
108
    my ($self, $params) = @_;
109
110
    my $patron = $params->{patron};
111
112
    my $record = $self->metadata->record;
113
114
    if ( $params->{embed_items} or $params->{opac} ) {
115
        # There's need for a RecordProcessor, let's do it!
116
        my @filters;
117
        my $options = {
118
            interface     => 'opac',
119
            frameworkcode => $self->frameworkcode,
120
        };
121
122
        if ($params->{embed_items}) {
123
            push @filters, 'EmbedItems';
124
            if ($params->{opac}) {
125
                $options->{items} = $self->items->filter_by_visible_in_opac(
126
                    {
127
                        ( $params->{patron} ? patron => $params->{patron} : ())
128
                    }
129
                );
130
            }
131
            else {
132
                $options->{items} = $self->items;
133
            }
134
        }
135
136
        if ( $params->{opac} ) {
137
            push @filters, 'ViewPolicy';
138
        }
139
140
        if ( $params->{expand_coded_fields} ) {
141
            push @filters, 'ExpandCodedFields';
142
        }
143
144
        my $rp = Koha::RecordProcessor->new(
145
            {
146
                filters => \@filters,
147
                options => $options
148
            }
149
        );
150
151
        $rp->process( $record );
152
    }
153
154
    return $record;
155
}
156
91
=head3 orders
157
=head3 orders
92
158
93
my $orders = $biblio->orders();
159
my $orders = $biblio->orders();
94
- 

Return to bug 31224