From 2359a7dd647c7398b3b5a4ae37e9c571e35f0861 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
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
Signed-off-by: Sam Lau <samalau@gmail.com>
---
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 ceaabf2aa1..59f1a8f574 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.39.2