From 8e38ef8a25aa7a3b1621779877c2521e809917f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Novotn=C3=BD?= <witiko@mail.muni.cz>
Date: Fri, 29 Jun 2018 18:59:53 +0200
Subject: [PATCH] Aleph driver: add dlfbaseurl config option

---
 config/vufind/Aleph.ini                       |  3 +++
 module/VuFind/src/VuFind/ILS/Driver/Aleph.php | 16 +++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/config/vufind/Aleph.ini b/config/vufind/Aleph.ini
index 5d24bb17825..3387a448a98 100644
--- a/config/vufind/Aleph.ini
+++ b/config/vufind/Aleph.ini
@@ -17,6 +17,9 @@ xport       = 80
 ; debug mode for logging errors
 debug       = false
 
+; override the host, and dlfport settings for Aleph REST API requests (optional)
+;dlfbaseurl  = http://aleph.mylibrary.edu:1891/rest-dlf/
+
 ; bibliographic library -- the library that your bibs are in - normally XXX01
 ; where XXX is a prefix that you have configured. It's the library you would
 ; search in your cataloging client.
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
index 6daf4f34474..681fa50488a 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
@@ -334,6 +334,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
      */
     protected $dateConverter = null;
 
+    /**
+     * The base URL, where the REST DLF API is running
+     *
+     * @var string
+     */
+    protected $dlfbaseurl = null;
+
     /**
      * Constructor
      *
@@ -388,6 +395,9 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
             $this->xserver_enabled = false;
         }
         $this->dlfport = $this->config['Catalog']['dlfport'];
+        if (isset($this->config['Catalog']['dlfbaseurl'])) {
+            $this->dlfbaseurl = $this->config['Catalog']['dlfbaseurl'];
+        }
         $this->sublibadm = $this->config['sublibadm'];
         if (isset($this->config['duedates'])) {
             $this->duedates = $this->config['duedates'];
@@ -480,7 +490,11 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
         $method = 'GET', $body = null
     ) {
         $path = implode('/', $path_elements);
-        $url = "http://$this->host:$this->dlfport/rest-dlf/" . $path;
+        if ($this->dlfbaseurl === null) {
+            $url = "http://$this->host:$this->dlfport/rest-dlf/" . $path;
+        } else {
+            $url = $this->dlfbaseurl . $path;
+        }
         $url = $this->appendQueryString($url, $params);
         $result = $this->doHTTPRequest($url, $method, $body);
         $replyCode = (string)$result->{'reply-code'};
-- 
GitLab