#
# 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 <http://www.gnu.org/licenses>.
=head1 NAME
=cut
-use strict;
-use warnings;
+use Modern::Perl;
+
use Module::Load::Conditional qw(can_load);
use Module::Pluggable::Object;
=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;
}
}
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 {