From c68b70fd60ccccc8154b30d36568bdff25013852 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 1 Mar 2013 12:10:49 -0500
Subject: [PATCH] Inject configuration.

---
 module/VuFind/config/module.config.php             |  7 ++++++-
 .../VuFind/RecordTab/CollectionHierarchyTree.php   |  7 +++++--
 .../VuFind/src/VuFind/RecordTab/HierarchyTree.php  | 14 ++++++++++----
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 5082081ed54..5ea3f1bacdd 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -627,6 +627,7 @@ $config = array(
                 'factories' => array(
                     'collectionhierarchytree' => function ($sm) {
                         return new \VuFind\RecordTab\CollectionHierarchyTree(
+                            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
                             $sm->getServiceLocator()->get('VuFind\RecordLoader')
                         );
                     },
@@ -636,6 +637,11 @@ $config = array(
                             $searchManager->setSearchClassId('SolrCollection')->getResults()
                         );
                     },
+                    'hierarchytree' => function ($sm) {
+                        return new \VuFind\RecordTab\HierarchyTree(
+                            $sm->getServiceLocator()->get('VuFind\Config')->get('config')
+                        );
+                    },
                     'holdingsils' => function ($sm) {
                         // If VuFind is configured to suppress the holdings tab when the
                         // ILS driver specifies no holdings, we need to pass in a connection
@@ -654,7 +660,6 @@ $config = array(
                 'invokables' => array(
                     'description' => 'VuFind\RecordTab\Description',
                     'excerpt' => 'VuFind\RecordTab\Excerpt',
-                    'hierarchytree' => 'VuFind\RecordTab\HierarchyTree',
                     'holdingsworldcat' => 'VuFind\RecordTab\HoldingsWorldCat',
                     'map' => 'VuFind\RecordTab\Map',
                     'reviews' => 'VuFind\RecordTab\Reviews',
diff --git a/module/VuFind/src/VuFind/RecordTab/CollectionHierarchyTree.php b/module/VuFind/src/VuFind/RecordTab/CollectionHierarchyTree.php
index 6ce6fdb5c80..493fee2784d 100644
--- a/module/VuFind/src/VuFind/RecordTab/CollectionHierarchyTree.php
+++ b/module/VuFind/src/VuFind/RecordTab/CollectionHierarchyTree.php
@@ -48,10 +48,13 @@ class CollectionHierarchyTree extends HierarchyTree
     /**
      * Constructor
      *
+     * @param \Zend\Config\Config   $config Configuration
      * @param \VuFind\Record\Loader $loader Record loader
      */
-    public function __construct(\VuFind\Record\Loader $loader)
-    {
+    public function __construct(\Zend\Config\Config $config,
+        \VuFind\Record\Loader $loader
+    ) {
+        parent::__construct($config);
         $this->loader = $loader;
     }
 
diff --git a/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php b/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php
index dff411f10e7..00ad966e998 100644
--- a/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php
+++ b/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php
@@ -26,7 +26,6 @@
  * @link     http://vufind.org/wiki/vufind2:record_tabs Wiki
  */
 namespace VuFind\RecordTab;
-use VuFind\Config\Reader as ConfigReader;
 
 /**
  * HierarchyTree tab
@@ -53,6 +52,16 @@ class HierarchyTree extends AbstractBase
      */
     protected $config = null;
 
+    /**
+     * Constructor
+     *
+     * @param \Zend\Config\Config $config Configuration
+     */
+    public function __construct(\Zend\Config\Config $config)
+    {
+        $this->config = $config;
+    }
+
     /**
      * Get the VuFind configuration.
      *
@@ -60,9 +69,6 @@ class HierarchyTree extends AbstractBase
      */
     protected function getConfig()
     {
-        if (null === $this->config) {
-            $this->config = ConfigReader::getConfig();
-        }
         return $this->config;
     }
 
-- 
GitLab