From 45bebcdf383e032c921ff46172adc3aaad86ef80 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 6 Feb 2015 11:23:12 -0500
Subject: [PATCH] Take advantage of HttpServiceAwareTrait.

---
 .../VuDL/src/VuDL/Connection/AbstractBase.php | 21 ++----------------
 module/VuFind/src/VuFind/Auth/Facebook.php    | 19 +---------------
 .../src/VuFind/Content/AbstractBase.php       | 19 +---------------
 .../src/VuFind/Content/Covers/Amazon.php      | 21 ++----------------
 .../src/VuFind/Content/Covers/Google.php      | 19 +---------------
 module/VuFind/src/VuFind/ILS/Driver/Aleph.php | 21 ++----------------
 .../src/VuFind/ILS/Driver/HorizonXMLAPI.php   | 19 +---------------
 .../src/VuFind/ILS/Driver/Innovative.php      | 19 +---------------
 .../VuFind/src/VuFind/ILS/Driver/Polaris.php  | 21 ++----------------
 .../VuFind/src/VuFind/ILS/Driver/Unicorn.php  | 21 ++----------------
 .../VuFind/src/VuFind/ILS/Driver/Virtua.php   | 21 ++----------------
 .../src/VuFind/ILS/Driver/VoyagerRestful.php  | 21 ++----------------
 .../VuFind/src/VuFind/ILS/Driver/XCNCIP2.php  | 22 ++-----------------
 .../src/VuFind/Recommend/EuropeanaResults.php | 21 ++----------------
 .../VuFind/Recommend/OpenLibrarySubjects.php  | 21 ++----------------
 15 files changed, 25 insertions(+), 281 deletions(-)

diff --git a/module/VuDL/src/VuDL/Connection/AbstractBase.php b/module/VuDL/src/VuDL/Connection/AbstractBase.php
index 2afe045900a..32372148bcb 100644
--- a/module/VuDL/src/VuDL/Connection/AbstractBase.php
+++ b/module/VuDL/src/VuDL/Connection/AbstractBase.php
@@ -40,6 +40,8 @@ use VuFindHttp\HttpServiceInterface,
  */
 class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * VuDL config
      *
@@ -54,13 +56,6 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
      */
     protected $parentLists = array();
 
-    /**
-     * HTTP service
-     *
-     * @var HttpServiceInterface
-     */
-    protected $httpService = false;
-
     /**
      * Constructor
      *
@@ -71,18 +66,6 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
         $this->config = $config;
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Get root id from config
      *
diff --git a/module/VuFind/src/VuFind/Auth/Facebook.php b/module/VuFind/src/VuFind/Auth/Facebook.php
index 14aeb89145e..b14e3748152 100644
--- a/module/VuFind/src/VuFind/Auth/Facebook.php
+++ b/module/VuFind/src/VuFind/Auth/Facebook.php
@@ -42,12 +42,7 @@ use VuFind\Exception\Auth as AuthException;
 class Facebook extends AbstractBase implements
     \VuFindHttp\HttpServiceAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Session container
@@ -64,18 +59,6 @@ class Facebook extends AbstractBase implements
         $this->session = new \Zend\Session\Container('Facebook');
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Validate configuration parameters.  This is a support method for getConfig(),
      * so the configuration MUST be accessed using $this->config; do not call
diff --git a/module/VuFind/src/VuFind/Content/AbstractBase.php b/module/VuFind/src/VuFind/Content/AbstractBase.php
index b4354d8a18b..ac621ecd00b 100644
--- a/module/VuFind/src/VuFind/Content/AbstractBase.php
+++ b/module/VuFind/src/VuFind/Content/AbstractBase.php
@@ -40,12 +40,7 @@ use VuFindCode\ISBN;
 abstract class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface,
     \Zend\Log\LoggerAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Logger
@@ -96,18 +91,6 @@ abstract class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface,
         return $this->httpService->createClient($url);
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Load results for a particular API key and ISBN.
      *
diff --git a/module/VuFind/src/VuFind/Content/Covers/Amazon.php b/module/VuFind/src/VuFind/Content/Covers/Amazon.php
index 11510824ad1..1a000682c20 100644
--- a/module/VuFind/src/VuFind/Content/Covers/Amazon.php
+++ b/module/VuFind/src/VuFind/Content/Covers/Amazon.php
@@ -40,6 +40,8 @@ use ZendService\Amazon\Amazon as AmazonService;
 class Amazon extends \VuFind\Content\AbstractCover
     implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Associate ID
      *
@@ -54,13 +56,6 @@ class Amazon extends \VuFind\Content\AbstractCover
      */
     protected $secret;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
     /**
      * Constructor
      *
@@ -89,18 +84,6 @@ class Amazon extends \VuFind\Content\AbstractCover
         return $this->httpService->createClient($url);
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Get image URL for a particular API key and set of IDs (or false if invalid).
      *
diff --git a/module/VuFind/src/VuFind/Content/Covers/Google.php b/module/VuFind/src/VuFind/Content/Covers/Google.php
index 782f380b45b..47c77110eb8 100644
--- a/module/VuFind/src/VuFind/Content/Covers/Google.php
+++ b/module/VuFind/src/VuFind/Content/Covers/Google.php
@@ -39,12 +39,7 @@ namespace VuFind\Content\Covers;
 class Google extends \VuFind\Content\AbstractCover
     implements \VuFindHttp\HttpServiceAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Constructor
@@ -69,18 +64,6 @@ class Google extends \VuFind\Content\AbstractCover
         return $this->httpService->createClient($url);
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Get image URL for a particular API key and set of IDs (or false if invalid).
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
index 1d57fbb815d..b209bfe39c4 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php
@@ -304,6 +304,8 @@ class AlephRestfulException extends ILSException
 class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
     \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Duedate configuration
      *
@@ -332,13 +334,6 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
      */
     protected $logger = false;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
     /**
      * Date converter object
      *
@@ -371,18 +366,6 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
         $this->logger = $logger;
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php
index 59957990b9b..a568765c0f1 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php
@@ -41,24 +41,7 @@ use VuFind\Exception\ILS as ILSException;
  */
 class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Initialize the driver.
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php
index 3434549a1a7..a7132da4ce2 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php
@@ -43,24 +43,7 @@ use VuFind\Exception\ILS as ILSException;
 class Innovative extends AbstractBase implements
     \VuFindHttp\HttpServiceAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Initialize the driver.
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Polaris.php b/module/VuFind/src/VuFind/ILS/Driver/Polaris.php
index 783949651d2..32bce071e59 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Polaris.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Polaris.php
@@ -41,6 +41,8 @@ use VuFind\Config\Reader as ConfigReader,
  */
 class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Web services host
      *
@@ -76,25 +78,6 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf
      */
     protected $ws_requestingorgid;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php
index e5afc0559c1..302f1f21687 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php
@@ -44,6 +44,8 @@ use File_MARC, VuFind\Exception\ILS as ILSException;
  **/
 class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Host
      *
@@ -72,13 +74,6 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf
      */
     protected $url;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
     /**
      * Date converter object
      *
@@ -96,18 +91,6 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf
         $this->dateConverter = $dateConverter;
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php
index 4818b19316b..b3e1094ce23 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php
@@ -39,6 +39,8 @@ use VuFind\Exception\ILS as ILSException;
  */
 class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Oracle connection
      *
@@ -46,25 +48,6 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa
      */
     protected $db;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php
index 9b2076799e6..42f8cb20c4f 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php
@@ -48,6 +48,8 @@ use PDO, PDOException, VuFind\Exception\Date as DateException,
  */
 class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Web services host
      *
@@ -111,13 +113,6 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte
      */
     protected $callSlipCheckLimit;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
     /**
      * Holds mode
      *
@@ -227,18 +222,6 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte
         $this->titleHoldsMode = $titleHoldsMode;
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php
index cd3ecf4757a..9261cb23f6e 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php
@@ -40,12 +40,7 @@ use VuFind\Exception\ILS as ILSException,
  */
 class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
 {
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
+    use \VuFindHttp\HttpServiceAwareTrait;
 
     /**
      * Is this a consortium? Default: false
@@ -75,18 +70,6 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf
      */
     protected $pickupLocations = array();
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Initialize the driver.
      *
@@ -160,8 +143,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf
     {
         // Make the NCIP request:
         try {
-            $client = $this->httpService
-                ->createClient($this->url);
+            $client = $this->httpService->createClient($this->url);
             // Set timeout value
             $timeout = isset($this->config['Catalog']['http_timeout'])
             ? $this->config['Catalog']['http_timeout'] : 30;
diff --git a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
index bbe8d472256..471213aba60 100644
--- a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
+++ b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
@@ -44,6 +44,8 @@ use Zend\Feed\Reader\Reader as FeedReader, Zend\Log\LoggerInterface;
 class EuropeanaResults implements RecommendInterface,
     \VuFindHttp\HttpServiceAwareInterface, \Zend\Log\LoggerAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Request parameter for searching
      *
@@ -121,13 +123,6 @@ class EuropeanaResults implements RecommendInterface,
      */
     protected $logger = false;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
     /**
      * Constructor
      *
@@ -138,18 +133,6 @@ class EuropeanaResults implements RecommendInterface,
         $this->key = $key;
     }
 
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * Set the logger
      *
diff --git a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php
index c325ae7b62e..86397a72698 100644
--- a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php
+++ b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php
@@ -45,6 +45,8 @@ use VuFind\Connection\OpenLibrary, VuFind\Solr\Utils as SolrUtils;
 class OpenLibrarySubjects implements RecommendInterface,
     \VuFindHttp\HttpServiceAwareInterface
 {
+    use \VuFindHttp\HttpServiceAwareTrait;
+
     /**
      * Parameter to use for search terms
      *
@@ -94,25 +96,6 @@ class OpenLibrarySubjects implements RecommendInterface,
      */
     protected $result = false;
 
-    /**
-     * HTTP service
-     *
-     * @var \VuFindHttp\HttpServiceInterface
-     */
-    protected $httpService = null;
-
-    /**
-     * Set the HTTP service to be used for HTTP requests.
-     *
-     * @param HttpServiceInterface $service HTTP service
-     *
-     * @return void
-     */
-    public function setHttpService(\VuFindHttp\HttpServiceInterface $service)
-    {
-        $this->httpService = $service;
-    }
-
     /**
      * setConfig
      *
-- 
GitLab