From 1da440c52c8c7c76871f2db8b9972fd168a2ea45 Mon Sep 17 00:00:00 2001
From: Dorian Merz <merz@ub.uni-leipzig.de>
Date: Wed, 5 Aug 2020 13:02:24 +0200
Subject: [PATCH] refs #18069 [master] fix hierarchy tab config

* use finc-specific generalized factory
---
 module/finc/config/module.config.php          |  2 +-
 .../finc/src/finc/RecordTab/HierarchyTree.php | 17 -----
 .../finc/RecordTab/HierarchyTreeFactory.php   | 63 +++++++++++++++++++
 3 files changed, 64 insertions(+), 18 deletions(-)
 create mode 100644 module/finc/src/finc/RecordTab/HierarchyTreeFactory.php

diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php
index ecf42016f54..401440dc5d3 100644
--- a/module/finc/config/module.config.php
+++ b/module/finc/config/module.config.php
@@ -155,7 +155,7 @@ $config = [
                     'finc\RecordTab\AcquisitionPDA' => 'Zend\ServiceManager\Factory\InvokableFactory',
                     'finc\RecordTab\Topics' => 'Zend\ServiceManager\Factory\InvokableFactory',
                     'finc\RecordTab\DescriptionLido' => 'Zend\ServiceManager\Factory\InvokableFactory',
-                    'finc\RecordTab\HierarchyTree' => 'VuFind\RecordTab\Factory::getHierarchyTree',
+                    'finc\RecordTab\HierarchyTree' => 'finc\RecordTab\HierarchyTreeFactory',
                 ],
                 'aliases' => [
                     'VuFind\RecordTab\HierarchyTree' => 'finc\RecordTab\HierarchyTree',
diff --git a/module/finc/src/finc/RecordTab/HierarchyTree.php b/module/finc/src/finc/RecordTab/HierarchyTree.php
index 1c6eb81bf94..cfc6a02c43c 100644
--- a/module/finc/src/finc/RecordTab/HierarchyTree.php
+++ b/module/finc/src/finc/RecordTab/HierarchyTree.php
@@ -45,23 +45,6 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree
      */
     protected $treeList = null;
 
-    /**
-     * Configuration
-     *
-     * @var \Zend\Config\Config
-     */
-    protected $config = null;
-
-    /**
-     * Constructor
-     *
-     * @param \Zend\Config\Config $config Configuration
-     */
-    public function __construct(\Zend\Config\Config $config)
-    {
-        $this->config = $config;
-    }
-
     public function getDescription()
     {
         if ($this->driver->isCollection()) return 'collection_hierarchy_tree_tab';
diff --git a/module/finc/src/finc/RecordTab/HierarchyTreeFactory.php b/module/finc/src/finc/RecordTab/HierarchyTreeFactory.php
new file mode 100644
index 00000000000..7c2b1c7672f
--- /dev/null
+++ b/module/finc/src/finc/RecordTab/HierarchyTreeFactory.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Record Tab Invokable Factory Class
+ * for HierarchyTree tab
+ *
+ * PHP version 7
+ *
+ * Copyright (C) Leipzig University Library, 2020.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * @category VuFind
+ * @package  RecordTab
+ * @author   Dorian Merz <merz@ub.uni-leipzig.de>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
+ */
+namespace finc\RecordTab;
+
+use Zend\ServiceManager\ServiceManager;
+
+/**
+ * Record Tab Invokable Factory Class
+ * for HierarchyTree tab
+ *
+ * @category VuFind
+ * @package  RecordTab
+ * @author   Dorian Merz <merz@ub.uni-leipzig.de>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
+ *
+ * @codeCoverageIgnore
+ */
+class HierarchyTreeFactory
+{
+    /**
+     * Factory for HierarchyTree tab plugin.
+     *
+     * @param ServiceManager $sm Service manager.
+     *
+     * @return HierarchyTree
+     */
+    public function __invoke(ServiceManager $sm, $requestedName, array $options = null)
+    {
+        if (!empty($options)) {
+            throw new \ConfigurationException('Unexpected options');
+        }
+        return new $requestedName(
+            $sm->get('VuFind\Config\PluginManager')->get('config')
+        );
+    }
+}
-- 
GitLab