@@ -, +, @@ --- Koha/Illrequest.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) --- a/Koha/Illrequest.pm +++ a/Koha/Illrequest.pm @@ -28,6 +28,7 @@ use Koha::Illrequest; use Koha::Illrequestattributes; use Koha::Patron; use Mail::Sendmail; +use Try::Tiny; use base qw(Koha::Object); @@ -157,6 +158,31 @@ sub _backend { return $self->{_my_backend}; } +=head3 _backend_capability + + my $backend_capability_result = $self->_backend_capability($name, $args); + +This is a helper method to invoke optional capabilities in the backend. If +the capability named by $name is not supported, return 0, else invoke it, +passing $args along with the invocation, and return its return value. + +=cut + +sub _backend_capability { + my ( $self, $name, $args ) = @_; + my $capability = 0; + try { + $capability = $self->_backend->capabilities($name); + } catch { + return 0; + }; + if ( $capability ) { + return $capability($args); + } else { + return 0; + } +} + =head3 _config my $config = $abstract->_config($config); --