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

(-)a/Koha/Biblio.pm (-15 / +11 lines)
Lines 28-39 use Koha::DateUtils qw( dt_from_string ); Link Here
28
28
29
use base qw(Koha::Object);
29
use base qw(Koha::Object);
30
30
31
use Koha::Items;
32
use Koha::Biblioitems;
33
use Koha::ArticleRequests;
34
use Koha::ArticleRequest::Status;
31
use Koha::ArticleRequest::Status;
32
use Koha::ArticleRequests;
33
use Koha::Biblio::Metadatas;
34
use Koha::Biblioitems;
35
use Koha::IssuingRules;
35
use Koha::IssuingRules;
36
use Koha::Item::Transfer::Limits;
36
use Koha::Item::Transfer::Limits;
37
use Koha::Items;
37
use Koha::Libraries;
38
use Koha::Libraries;
38
use Koha::Subscriptions;
39
use Koha::Subscriptions;
39
40
Lines 61-85 sub store { Link Here
61
    return $self->SUPER::store;
62
    return $self->SUPER::store;
62
}
63
}
63
64
64
=head3 marc
65
=head3 metadata
65
66
my @marc = $biblio->marc($params);
67
66
68
Returns a MARC::Record object for a record.
67
my $metadata = $biblio->metadata();
69
68
70
This method accepts the same paramters as C4::Biblio::GetMarcBiblio,
69
Returns a Koha::Biblio::Metadata object
71
but does not require the 'biblionumber' parameter.
72
70
73
=cut
71
=cut
74
72
75
sub marc {
73
sub metadata {
76
    my ( $self, $params ) = @_;
74
    my ( $self ) = @_;
77
78
    $params->{biblionumber} = $self->id;
79
75
80
    my $marc = C4::Biblio::GetMarcBiblio($params);
76
    $self->{_metadata} ||= Koha::Biblio::Metadatas->find( { biblionumber => $self->id } );
81
77
82
    return $marc;
78
    return $self->{_metadata};
83
}
79
}
84
80
85
=head3 subtitles
81
=head3 subtitles
(-)a/Koha/Biblio/Metadata.pm (+24 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use C4::Biblio qw();
23
22
use Koha::Database;
24
use Koha::Database;
23
25
24
use base qw(Koha::Object);
26
use base qw(Koha::Object);
Lines 33-38 Koha::Metadata - Koha Metadata Object class Link Here
33
35
34
=cut
36
=cut
35
37
38
=head3 record
39
40
my @record = $biblio->record($params);
41
42
Returns a MARC::Record object for a record.
43
44
This method accepts the same paramters as C4::Biblio::GetMarcBiblio,
45
but does not require the 'biblionumber' parameter.
46
47
=cut
48
49
sub record {
50
    my ( $self, $params ) = @_;
51
52
    $params->{biblionumber} = $self->biblionumber;
53
54
    my $record = C4::Biblio::GetMarcBiblio($params);
55
56
    return $record;
57
}
58
59
36
=head3 type
60
=head3 type
37
61
38
=cut
62
=cut
(-)a/t/db_dependent/Koha/Biblio.t (-5 / +7 lines)
Lines 36-42 $schema->storage->txn_begin; Link Here
36
my $dbh = C4::Context->dbh;
36
my $dbh = C4::Context->dbh;
37
37
38
subtest 'Test Koha::Biblio::marc()' => sub {
38
subtest 'Test Koha::Biblio::marc()' => sub {
39
    plan tests => 3;
39
    plan tests => 4;
40
40
41
    my $title = 'Oranges and Peaches';
41
    my $title = 'Oranges and Peaches';
42
42
Lines 48-57 subtest 'Test Koha::Biblio::marc()' => sub { Link Here
48
    my $biblio = Koha::Biblios->find( $biblionumber );
48
    my $biblio = Koha::Biblios->find( $biblionumber );
49
    is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' );
49
    is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' );
50
50
51
    my $marc = $biblio->marc();
51
    my $metadata = $biblio->metadata;
52
    is( ref $marc, 'MARC::Record', 'Method marc() returned a MARC::Record object' );
52
    is( ref $metadata, 'Koha::Biblio::Metadata', 'Method metadata() returned a Koha::Biblio::Metadata object' );
53
53
54
    is( $marc->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' );
54
    my $record2 = $metadata->record();
55
    is( ref $record2, 'MARC::Record', 'Method record() returned a MARC::Record object' );
56
57
    is( $record2->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' );
55
};
58
};
56
59
57
$schema->storage->txn_rollback;
60
$schema->storage->txn_rollback;
58
- 

Return to bug 22144