Bugzilla – Attachment 94029 Details for
Bug 23807
Add Koha::Item->as_marc_field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23807: Add Koha::Item->as_marc_field
Bug-23807-Add-KohaItem-asmarcfield.patch (text/plain), 2.16 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-10-11 17:44:35 UTC
(
hide
)
Description:
Bug 23807: Add Koha::Item->as_marc_field
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-10-11 17:44:35 UTC
Size:
2.16 KB
patch
obsolete
>From 43e9d358dd217a0338d1b88f4813bb5637b8c1d5 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 11 Oct 2019 14:43:09 -0300 >Subject: [PATCH] Bug 23807: Add Koha::Item->as_marc_field > >--- > Koha/Item.pm | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 552e977e97..2b2eb5fffc 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -26,6 +26,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > > use C4::Context; >+ > use Koha::Checkouts; > use Koha::IssuingRules; > use Koha::Item::Transfer::Limits; >@@ -385,6 +386,49 @@ sub has_pending_hold { > return !C4::Context->preference('AllowItemsOnHoldCheckout') && $pending_hold->count ? 1: 0; > } > >+=head3 as_marc_field >+ >+ my $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } ); >+ my $field = $item->as_marc_field({ [ mss => $mss ] }); >+ >+This method returns a MARC::Field object representing the Koha::Item object >+with the current mappings configuration. >+ >+=cut >+ >+sub as_marc_field { >+ my ( $self, $params ) = @_; >+ >+ my $mss = $params->{mss} // C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } ); >+ my $item_tag = $mss->{'items.itemnumber'}[0]->{tagfield}; >+ >+ my @subfields; >+ >+ my @columns = $self->_result->result_source->columns; >+ >+ foreach my $item_field ( @columns ) { >+ my $mapping = $mss->{ "items.$item_field"}[0]; >+ my $tagfield = $mapping->{tagfield}; >+ my $tagsubfield = $mapping->{tagsubfield}; >+ next if !$tagfield; # TODO: Should we raise an exception instead? >+ # Feels like safe fallback is better >+ >+ push @subfields, $tagsubfield => $self->$item_field; >+ } >+ >+ my $unlinked_item_subfields = C4::Items::_parse_unlinked_item_subfields_from_xml($self->more_subfields_xml); >+ push( @subfields, @{$unlinked_item_subfields} ) >+ if defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1; >+ >+ my $field; >+ >+ $field = MARC::Field->new( >+ "$item_tag", ' ', ' ', @subfields >+ ) if @subfields; >+ >+ return $field; >+} >+ > =head2 Internal methods > > =head3 _type >-- >2.23.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23807
:
94029
|
94094
|
94274
|
94275
|
94279
|
94280