From ca35e8ebed299729a6891527e5cc839ef02e81fe Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 1 Mar 2013 11:42:06 -0500
Subject: [PATCH] Inject configuration.

---
 .../src/VuFind/Controller/OaiController.php      |  2 +-
 module/VuFind/src/VuFind/OAI/Server.php          | 16 +++++++++-------
 module/VuFind/src/VuFind/OAI/Server/Auth.php     | 14 +++++++++-----
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/OaiController.php b/module/VuFind/src/VuFind/Controller/OaiController.php
index 2ce781103c7..1f4466ca2bd 100644
--- a/module/VuFind/src/VuFind/Controller/OaiController.php
+++ b/module/VuFind/src/VuFind/Controller/OaiController.php
@@ -96,7 +96,7 @@ class OaiController extends AbstractBase
         // Build OAI response or die trying:
         try {
             $server = new $serverClass(
-                $this->getSearchManager(),
+                $this->getSearchManager(), $config,
                 $baseURL, $this->getRequest()->getQuery()->toArray()
             );
             $xml = $server->getResponse();
diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php
index ad4cb3b0284..708b9ed793a 100644
--- a/module/VuFind/src/VuFind/OAI/Server.php
+++ b/module/VuFind/src/VuFind/OAI/Server.php
@@ -26,7 +26,7 @@
  * @link     http://vufind.org/wiki/vufind2:developer_manual Wiki
  */
 namespace VuFind\OAI;
-use SimpleXMLElement, VuFind\Config\Reader as ConfigReader,
+use SimpleXMLElement,
     VuFind\Exception\RecordMissing as RecordMissingException, VuFind\SimpleXML;
 
 /**
@@ -71,19 +71,21 @@ class Server
      * Constructor
      *
      * @param \VuFind\Search\Manager $sm      Search manager for retrieving records
+     * @param \Zend\Config\Config    $config  VuFind configuration
      * @param string                 $baseURL The base URL for the OAI server
      * @param array                  $params  The incoming OAI-PMH parameters
      * (i.e. $_GET)
      */
-    public function __construct(\VuFind\Search\Manager $sm, $baseURL, $params)
-    {
+    public function __construct(\VuFind\Search\Manager $sm,
+        \Zend\Config\Config $config, $baseURL, $params
+    ) {
         $this->searchManager = $sm;
         $this->tableManager = $sm->getServiceLocator()
             ->get('VuFind\DbTablePluginManager');
         $this->baseURL = $baseURL;
         $this->params = isset($params) && is_array($params) ? $params : array();
         $this->initializeMetadataFormats(); // Load details on supported formats
-        $this->initializeSettings();        // Load config.ini settings
+        $this->initializeSettings($config); // Load config.ini settings
     }
 
     /**
@@ -327,12 +329,12 @@ class Server
      * constructor and is only a separate method to allow easy override by child
      * classes).
      *
+     * @param \Zend\Config\Config $config VuFind configuration
+     *
      * @return void
      */
-    protected function initializeSettings()
+    protected function initializeSettings(\Zend\Config\Config $config)
     {
-        $config = ConfigReader::getConfig();
-
         // Override default repository name if configured:
         if (isset($config->OAI->repository_name)) {
             $this->repositoryName = $config->OAI->repository_name;
diff --git a/module/VuFind/src/VuFind/OAI/Server/Auth.php b/module/VuFind/src/VuFind/OAI/Server/Auth.php
index 761a9bec172..3cfec572068 100644
--- a/module/VuFind/src/VuFind/OAI/Server/Auth.php
+++ b/module/VuFind/src/VuFind/OAI/Server/Auth.php
@@ -45,13 +45,15 @@ class Auth extends Base
      * Constructor
      *
      * @param \VuFind\Search\Manager $sm      Search manager for retrieving records
+     * @param \Zend\Config\Config    $config  VuFind configuration
      * @param string                 $baseURL The base URL for the OAI server
      * @param array                  $params  The incoming OAI-PMH parameters
      * (i.e. $_GET)
      */
-    public function __construct(\VuFind\Search\Manager $sm, $baseURL, $params)
-    {
-        parent::__construct($sm, $baseURL, $params);
+    public function __construct(\VuFind\Search\Manager $sm,
+        \Zend\Config\Config $config, $baseURL, $params
+    ) {
+        parent::__construct($sm, $config, $baseURL, $params);
         $this->core = 'authority';
         $this->searchClassId = 'SolrAuth';
     }
@@ -61,13 +63,15 @@ class Auth extends Base
      * constructor and is only a separate method to allow easy override by child
      * classes).
      *
+     * @param \Zend\Config\Config $config VuFind configuration
+     *
      * @return void
      */
-    protected function initializeSettings()
+    protected function initializeSettings(\Zend\Config\Config $config)
     {
         // Use some of the same settings as the regular OAI server, but override
         // others:
-        parent::initializeSettings();
+        parent::initializeSettings($config);
         $this->repositoryName = 'Authority Data Store';
         $this->setField = 'source';
     }
-- 
GitLab