diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 5ea3f1bacddcb948e0ec6dc0f9780842c842b92e..229773a8ec3ca1926e17ae05c921b4a7858c36e2 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 b3a72940252402c745063539164218becdb7a03a..0f0937f313bf8e0fb7493170ca0e0abb9a297fbe 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');