From 631d35437f0551efdec9162f057747fe61ba5502 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 7 Aug 2014 15:19:07 -0400
Subject: [PATCH] Eliminated redundant code.

---
 .../src/VuFindSearch/Backend/EIT/Backend.php  | 124 +-----------------
 1 file changed, 3 insertions(+), 121 deletions(-)

diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Backend.php
index c0eab35d93c..d490efe7732 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Backend.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Backend.php
@@ -36,9 +36,7 @@ use VuFindSearch\ParamBag;
 use VuFindSearch\Response\RecordCollectionInterface;
 use VuFindSearch\Response\RecordCollectionFactoryInterface;
 
-use VuFindSearch\Backend\BackendInterface;
-
-use Zend\Log\LoggerInterface;
+use VuFindSearch\Backend\AbstractBackend;
 
 /**
  * EIT backend.
@@ -49,22 +47,8 @@ use Zend\Log\LoggerInterface;
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org
  */
-class Backend implements BackendInterface
+class Backend extends AbstractBackend
 {
-    /**
-     * Record collection factory.
-     *
-     * @var RecordCollectionFactoryInterface
-     */
-    protected $collectionFactory;
-
-    /**
-     * Logger, if any.
-     *
-     * @var LoggerInterface
-     */
-    protected $logger;
-
     /**
      * Connector.
      *
@@ -72,13 +56,6 @@ class Backend implements BackendInterface
      */
     protected $connector;
 
-    /**
-     * Backend identifier.
-     *
-     * @var string
-     */
-    protected $identifier;
-
     /**
      * Query builder.
      *
@@ -99,34 +76,6 @@ class Backend implements BackendInterface
     ) {
         $this->setRecordCollectionFactory($factory);
         $this->connector    = $connector;
-        $this->identifier   = null;
-    }
-
-
-    /**
-     * Log a debug message.
-     *
-     * @param string $msg Message to log.
-     *
-     * @return void
-     */
-    protected function debug($msg)
-    {
-        if ($this->logger) {
-            $this->logger->debug($msg);
-        }
-    }
-
-    /**
-     * Set the backend identifier.
-     *
-     * @param string $identifier Backend identifier
-     *
-     * @return void
-     */
-    public function setIdentifier($identifier)
-    {
-        $this->identifier = $identifier;
     }
 
     /**
@@ -144,7 +93,7 @@ class Backend implements BackendInterface
     ) {
         $params->mergeWith($this->getQueryBuilder()->build($query));
         $response   = $this->connector->search($params, $offset, $limit);
-        $this->debug(print_r($response, true));
+        $this->log('debug', print_r($response, true));
         $collection = $this->createRecordCollection($response);
         $this->injectSourceIdentifier($collection);
         return $collection;
@@ -166,18 +115,6 @@ class Backend implements BackendInterface
         return $collection;
     }
 
-    /**
-     * Set the Logger.
-     *
-     * @param LoggerInterface $logger Logger
-     *
-     * @return void
-     */
-    public function setLogger(LoggerInterface $logger)
-    {
-        $this->logger = $logger;
-    }
-
     /**
      * Return query builder.
      *
@@ -207,29 +144,6 @@ class Backend implements BackendInterface
         $this->queryBuilder = $queryBuilder;
     }
 
-    /**
-     * Return backend identifier.
-     *
-     * @return string
-     */
-    public function getIdentifier()
-    {
-        return $this->identifier;
-    }
-
-    /**
-     * Set the record collection factory.
-     *
-     * @param RecordCollectionFactoryInterface $factory Factory
-     *
-     * @return void
-     */
-    public function setRecordCollectionFactory(
-        RecordCollectionFactoryInterface $factory
-    ) {
-        $this->collectionFactory = $factory;
-    }
-
     /**
      * Return the record collection factory.
      *
@@ -254,38 +168,6 @@ class Backend implements BackendInterface
 
     /// Internal API
 
-    /**
-     * Inject source identifier in record collection and all contained records.
-     *
-     * @param ResponseInterface $response Response
-     *
-     * @return void
-     */
-    protected function injectSourceIdentifier(RecordCollectionInterface $response)
-    {
-        $response->setSourceIdentifier($this->identifier);
-        foreach ($response as $record) {
-            $record->setSourceIdentifier($this->identifier);
-        }
-        return $response;
-    }
-
-    /**
-     * Send a message to the logger.
-     *
-     * @param string $level   Log level
-     * @param string $message Log message
-     * @param array  $context Log context
-     *
-     * @return void
-     */
-    protected function log($level, $message, array $context = array())
-    {
-        if ($this->logger) {
-            $this->logger->$level($message, $context);
-        }
-    }
-
     /**
      * Create record collection.
      *
-- 
GitLab