1 package Koha
::Authority
;
3 # Copyright 2015 Koha Development Team
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use base
qw(Koha::Object);
32 Koha::Authority - Koha Authority Object class
48 =head2 get_all_authorities_iterator
50 my $it = Koha::Authority->get_all_authorities_iterator();
52 This will provide an iterator object that will, one by one, provide the
53 Koha::Authority of each authority.
55 The iterator is a Koha::MetadataIterator object.
59 sub get_all_authorities_iterator
{
60 my $database = Koha
::Database
->new();
61 my $schema = $database->schema();
63 $schema->resultset('AuthHeader')->search( { marcxml
=> { '!=', undef } },
64 { columns
=> [qw
/ authid authtypecode marcxml /] } );
66 my $row = $rs->next();
68 my $authid = $row->authid;
69 my $authtypecode = $row->authtypecode;
70 my $marcxml = $row->marcxml;
73 MARC
::Record
->new_from_xml(
74 StripNonXmlChars
($marcxml),
77 C4
::Context
->preference("marcflavour") eq "UNIMARC"
79 : C4
::Context
->preference("marcflavour")
84 $record->encoding('UTF-8');
86 # I'm not sure why we don't use the authtypecode from the database,
87 # but this is how the original code does it.
88 require C4
::AuthoritiesMarc
;
89 $authtypecode = C4
::AuthoritiesMarc
::GuessAuthTypeCode
($record);
91 my $auth = __PACKAGE__
->new( $record, $authid, $authtypecode );
95 return Koha
::MetadataIterator
->new($next_func);