Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
AbstractBase
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 getHierarchyDriver
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 setHierarchyDriver
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getCollectionRoute
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRecordRoute
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getJSON
n/a
0 / 0
n/a
0 / 0
0
 getXML
n/a
0 / 0
n/a
0 / 0
0
 supports
n/a
0 / 0
n/a
0 / 0
0
1<?php
2
3/**
4 * Hierarchy Tree Data Source (abstract base)
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 * @category VuFind
24 * @package  HierarchyTree_DataSource
25 * @author   Luke O'Sullivan <l.osullivan@swansea.ac.uk>
26 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27 * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
28 */
29
30namespace VuFind\Hierarchy\TreeDataSource;
31
32/**
33 * Hierarchy Tree Data Source (abstract base)
34 *
35 * This is a base helper class for producing hierarchy Trees.
36 *
37 * @category VuFind
38 * @package  HierarchyTree_DataSource
39 * @author   Luke O'Sullivan <l.osullivan@swansea.ac.uk>
40 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
41 * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
42 */
43abstract class AbstractBase implements \Laminas\Log\LoggerAwareInterface
44{
45    use \VuFind\Log\LoggerAwareTrait;
46
47    /**
48     * Hierarchy driver
49     *
50     * @var \VuFind\Hierarchy\Driver\AbstractBase
51     */
52    protected $hierarchyDriver = null;
53
54    /**
55     * Collection page route.
56     *
57     * @var string
58     */
59    protected $collectionRoute = 'collection';
60
61    /**
62     * Record page route.
63     *
64     * @var string
65     */
66    protected $recordRoute = 'record';
67
68    /**
69     * Get the hierarchy driver
70     *
71     * @return \VuFind\Hierarchy\Driver\AbstractBase
72     * @throws \Exception
73     */
74    protected function getHierarchyDriver()
75    {
76        if (null === $this->hierarchyDriver) {
77            throw new \Exception('Missing hierarchy driver');
78        }
79        return $this->hierarchyDriver;
80    }
81
82    /**
83     * Set the hierarchy driver
84     *
85     * @param \VuFind\Hierarchy\Driver\AbstractBase $driver Hierarchy driver
86     *
87     * @return AbstractBase
88     */
89    public function setHierarchyDriver(\VuFind\Hierarchy\Driver\AbstractBase $driver)
90    {
91        $this->hierarchyDriver = $driver;
92        return $this;
93    }
94
95    /**
96     * Get collection page route.
97     *
98     * @return string
99     */
100    public function getCollectionRoute()
101    {
102        return $this->collectionRoute;
103    }
104
105    /**
106     * Get recordpage route.
107     *
108     * @return string
109     */
110    public function getRecordRoute()
111    {
112        return $this->recordRoute;
113    }
114
115    /**
116     * Get JSON for the specified hierarchy ID.
117     *
118     * Build the JSON file from the Solr fields
119     *
120     * @param string $id      Hierarchy ID.
121     * @param array  $options Additional options for JSON generation. (Currently one
122     * option is supported: 'refresh' may be set to true to bypass caching).
123     *
124     * @return string
125     */
126    abstract public function getJSON($id, $options = []);
127
128    /**
129     * Get XML for the specified hierarchy ID.
130     *
131     * @param string $id      Hierarchy ID.
132     * @param array  $options Additional options for XML generation.
133     *
134     * @return string
135     */
136    abstract public function getXML($id, $options = []);
137
138    /**
139     * Does this data source support the specified hierarchy ID?
140     *
141     * @param string $id Hierarchy ID.
142     *
143     * @return bool
144     */
145    abstract public function supports($id);
146}