From f039ae30523b52a6022d7a29cee3227280ffe1e4 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 26 Apr 2018 12:04:58 +0100 Subject: [PATCH] Bug 18837: Introduce delegation to backends for unmediated workflows This patch adds support to Illrequest.pm to allow delegation of unmediated requests to happen in backends that support them. It is a recreation of https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=66629&action=diff which had diverged sufficiently as to make it impossible to apply Signed-off-by: Stephen Graham Signed-off-by: David Peacock Signed-off-by: Jayne Maisey --- Koha/Illrequest.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 5f7019a139..ae7822344b 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -352,12 +352,14 @@ capabilities & custom_capability and their callers. sub _backend_capability { my ( $self, $name, $args ) = @_; my $capability = 0; + # See if capability is defined in backend try { $capability = $self->_backend->capabilities($name); } catch { return 0; }; - if ( $capability ) { + # Try to invoke it + if ( $capability && ref($capability) eq 'CODE' ) { return &{$capability}($args); } else { return 0; @@ -819,6 +821,20 @@ sub backend_create { # ...Updating status! $self->status('QUEUED')->store unless ( $permitted ); + ## Handle Unmediated ILLs + + # For the unmediated workflow we only need to delegate to our backend. If + # that backend supports unmediateld_ill, it will do its thing and return a + # proper response. If it doesn't then _backend_capability returns 0, so + # we keep the current result. + if ( C4::Context->preference("ILLModuleUnmediated") && $permitted ) { + my $unmediated_result = $self->_backend_capability( + 'unmediated_ill', + $args + ); + $result = $unmediated_result if $unmediated_result; + } + return $self->expandTemplate($result); } -- 2.11.0