Koha/Koha/SearchFields.pm
Alex Arnaud 9380134a02 Bug 18316: (follow-up) Koha::SearchField::search_marc_maps return a result set - code refactoring for gettings weighted fields - Koha::SearchFields::weighted_fields return a result set
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Rebased-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Ere Maijala <ere.maijala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-07 22:00:31 +00:00

65 lines
1.3 KiB
Perl

package Koha::SearchFields;
# 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 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.
#
# 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.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::SearchField;
use base qw(Koha::Objects);
=head1 NAME
Koha::SearchFields - Koha SearchField Object set class
=head1 API
=head2 Class Methods
=cut
=head3 weighted_fields
my (@w_fields, @weight) = Koha::SearchFields->weighted_fields();
=cut
sub weighted_fields {
my ($self) = @_;
return $self->search(
{ weight => { '>' => 0, '!=' => undef } },
{ order_by => { -desc => 'weight' } }
);
}
=head3 type
=cut
sub _type {
return 'SearchField';
}
sub object_class {
return 'Koha::SearchField';
}
1;