From f0197e30d41d76c3c950a945548910cd86c15718 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 1 Mar 2013 13:01:55 -0500
Subject: [PATCH] Inject configuration.

---
 module/VuFind/config/module.config.php     |  6 +++++-
 module/VuFind/src/VuFind/RecordTab/Map.php | 21 ++++++++++++++++++---
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 5ea3f1bacdd..229773a8ec3 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -656,12 +656,16 @@ $config = array(
                         }
                         return new \VuFind\RecordTab\HoldingsILS($catalog);
                     },
+                    'map' => function ($sm) {
+                        $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config');
+                        $enabled = isset($config->Content->recordMap);
+                        return new \VuFind\RecordTab\Map($enabled);
+                    },
                 ),
                 'invokables' => array(
                     'description' => 'VuFind\RecordTab\Description',
                     'excerpt' => 'VuFind\RecordTab\Excerpt',
                     'holdingsworldcat' => 'VuFind\RecordTab\HoldingsWorldCat',
-                    'map' => 'VuFind\RecordTab\Map',
                     'reviews' => 'VuFind\RecordTab\Reviews',
                     'staffviewarray' => 'VuFind\RecordTab\StaffViewArray',
                     'staffviewmarc' => 'VuFind\RecordTab\StaffViewMARC',
diff --git a/module/VuFind/src/VuFind/RecordTab/Map.php b/module/VuFind/src/VuFind/RecordTab/Map.php
index b3a72940252..0f0937f313b 100644
--- a/module/VuFind/src/VuFind/RecordTab/Map.php
+++ b/module/VuFind/src/VuFind/RecordTab/Map.php
@@ -26,7 +26,6 @@
  * @link     http://vufind.org/wiki/vufind2:record_tabs Wiki
  */
 namespace VuFind\RecordTab;
-use VuFind\Config\Reader as ConfigReader;
 
 /**
  * Map tab
@@ -47,6 +46,23 @@ class Map extends AbstractBase
      */
     protected $translator = null;
 
+    /**
+     * Is this module enabled in the configuration?
+     *
+     * @var bool
+     */
+    protected $enabled;
+
+    /**
+     * Constructor
+     *
+     * @param bool $enabled Is this module enabled in the configuration?
+     */
+    public function __construct($enabled = true)
+    {
+        $this->enabled = $enabled;
+    }
+
     /**
      * Get the on-screen description for this tab.
      *
@@ -121,8 +137,7 @@ class Map extends AbstractBase
      */
     public function isActive()
     {
-        $config = ConfigReader::getConfig();
-        if (!isset($config->Content->recordMap)) {
+        if (!$this->enabled) {
             return false;
         }
         $longLat = $this->getRecordDriver()->tryMethod('getLongLat');
-- 
GitLab