Koha/Koha/Template/Plugin/Context.pm
Jonathan Druart 992edc43b0 Bug 23166: Early return if no set
It prevents valid_template check to raise
Can't call method "filter_by_current" without a package or object reference at /kohadevbox/koha/Koha/Template/Plugin/Context.pm line 49.

Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-08-25 12:01:38 +02:00

54 lines
1.2 KiB
Perl

package Koha::Template::Plugin::Context;
# 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, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use base qw( Template::Plugin );
use C4::Context;
=head1 NAME
Koha::Template::Plugin::Scalar - Return object set in scalar context
=head1 SYNOPSIS
If you need to force scalar context when calling a method on a object set.
Especially useful to call ->search
=cut
=head1 API
=head2 Class Methods
=cut
=head3 Scalar
Return object set in scalar context
=cut
sub Scalar {
my ( $self, $set, $method ) = @_;
return unless $set;
$set = $set->$method;
return $set;
}
1;