From 50e1d95ca50b42e8f2da1bae530f80882351e5b9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 16 Jul 2024 15:21:04 -0300 Subject: [PATCH] Bug 37380: Add get_control_number() to the metadata extractor This simple patch implements C4::Biblio::GetMarcControlnumber in the right spot on the Koha::* namespace. To test: 1. Apply this patches 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC.t => SUCCESS: Tests pass! 3. Sign off :-D --- Koha/Biblio/Metadata/Extractor/MARC.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Koha/Biblio/Metadata/Extractor/MARC.pm b/Koha/Biblio/Metadata/Extractor/MARC.pm index ceaabf2aa19..59f1a8f5745 100644 --- a/Koha/Biblio/Metadata/Extractor/MARC.pm +++ b/Koha/Biblio/Metadata/Extractor/MARC.pm @@ -76,6 +76,25 @@ sub metadata { return $self->{metadata}; } +=head2 get_control_number + + my $control_number = $extractor->get_control_number(); + +Returns the control number/record identifier as extracted from the metadata. + +=cut + +sub get_control_number { + my ($self) = @_; + + my $record = $self->metadata; + my $field = $record->field('001'); + + if ($field) { + return $field->data(); + } +} + =head3 _normalize_string my $normalized_string = $self->_normalize_string($string); -- 2.45.2