X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=Koha%2FRecordProcessor.pm;h=1f93571d7b698684dabd087804acb90bf8a04441;hb=c8eeadf6644ea3a5c15ba488db28ee2c2725c9ec;hp=3d4e1bf6a69673c863b2a2a623af606c176ed6fe;hpb=e5a24bbbdd0d0e9ff09bfaadfe4c4bb37312e7ec;p=koha.git diff --git a/Koha/RecordProcessor.pm b/Koha/RecordProcessor.pm index 3d4e1bf6a6..1f93571d7b 100644 --- a/Koha/RecordProcessor.pm +++ b/Koha/RecordProcessor.pm @@ -4,18 +4,18 @@ package Koha::RecordProcessor; # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -57,8 +57,8 @@ clone it I to passing it off to the RecordProcessor. =cut -use strict; -use warnings; +use Modern::Perl; + use Module::Load::Conditional qw(can_load); use Module::Pluggable::Object; @@ -90,21 +90,27 @@ Koha::Filter::${schema} namespace, as only the filter name, and =cut sub new { + my $class = shift; my $param = shift; - my $schema = $param->{schema} || 'MARC'; + my $schema = $param->{schema} || 'MARC'; my $options = $param->{options} || ''; + + my $req_filters = ( ref($param->{filters}) ne 'ARRAY' ) + ? [ $param->{filters} ] + : $param->{filters}; my @filters = ( ); - foreach my $filter ($param->{filters}) { - next unless $filter; - my $filter_module = $filter =~ m/:/ ? $filter : "Koha::Filter::${schema}::${filter}"; + foreach my $filter_name (@{ $req_filters }) { + next unless $filter_name; + # Fully qualify the module name. + my $filter_module = $filter_name =~ m/:/ ? $filter_name : "Koha::Filter::${schema}::${filter_name}"; if (can_load( modules => { $filter_module => undef } )) { - my $object = $filter_module->new(); - $filter_module->initialize($param); - push @filters, $object; + my $filter = $filter_module->new(); + $filter->initialize($param); + push @filters, $filter; } } @@ -146,14 +152,12 @@ sub process { return unless defined $record; - my $newrecord = $record; - foreach my $filterobj (@{$self->filters}) { next unless $filterobj; - $newrecord = $filterobj->filter($newrecord); + $filterobj->filter($record); } - return $newrecord; + return $record; } sub DESTROY {