Bug 12478 - authorities can now be stored in ES
[srvgit] / Koha / Biblio.pm
index 9c467d7..38b53f9 100644 (file)
@@ -21,6 +21,8 @@ use Modern::Perl;
 
 use Carp;
 
+use C4::Biblio qw( GetRecordValue GetMarcBiblio GetFrameworkCode );
+
 use Koha::Database;
 
 use base qw(Koha::Object);
@@ -35,11 +37,42 @@ Koha::Biblio - Koha Biblio Object class
 
 =cut
 
+=head3 subtitles
+
+my @subtitles = $biblio->subtitles();
+
+Returns list of subtitles for a record.
+
+Keyword to MARC mapping for subtitle must be set for this method to return any possible values.
+
+=cut
+
+sub subtitles {
+    my ( $self ) = @_;
+
+    return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
+}
+
+=head3 items
+
+Returns the related Koha::Items object for this biblio in scalar context,
+or list of Koha::Item objects in list context.
+
+=cut
+
+sub items {
+    my ($self) = @_;
+
+    $self->{_items} ||= Koha::Items->search( { biblionumber => $self->biblionumber() } );
+
+    return wantarray ? $self->{_items}->as_list : $self->{_items};
+}
+
 =head3 type
 
 =cut
 
-sub type {
+sub _type {
     return 'Biblio';
 }