Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
AbstractConfig | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOptions | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | /** |
4 | * Abstract Configuration Module |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2018. |
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 GeoFeatures |
25 | * @author Leila Gonzales <lmg@agiweb.org> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki |
28 | */ |
29 | |
30 | namespace VuFind\GeoFeatures; |
31 | |
32 | use Laminas\Config\Config; |
33 | |
34 | /** |
35 | * MapTab Configuration Class |
36 | * |
37 | * @category VuFind |
38 | * @package GeoFeatures |
39 | * @author Leila Gonzales <lmg@agiweb.org> |
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 | */ |
43 | class AbstractConfig |
44 | { |
45 | /** |
46 | * Configuration loader |
47 | * |
48 | * @var \VuFind\Config\PluginManager |
49 | */ |
50 | protected $configLoader; |
51 | |
52 | /** |
53 | * Constructor |
54 | * |
55 | * @param \VuFind\Config\PluginManager $configLoader Configuration loader |
56 | */ |
57 | public function __construct(\VuFind\Config\PluginManager $configLoader) |
58 | { |
59 | $this->configLoader = $configLoader; |
60 | } |
61 | |
62 | /** |
63 | * Convert a config object to an options array; return empty array if |
64 | * configuration is missing or incomplete. |
65 | * |
66 | * @param string $configName Name of config file to read |
67 | * @param string $section Name of section to read |
68 | * @param array $validOptions List of valid fields to read |
69 | * |
70 | * @return array |
71 | */ |
72 | protected function getOptions($configName, $section, $validOptions) |
73 | { |
74 | $config = $this->configLoader->get($configName); |
75 | $options = []; |
76 | foreach ($validOptions as $field) { |
77 | if (isset($config->$section->$field)) { |
78 | $options[$field] = $config->$section->$field; |
79 | } |
80 | } |
81 | return $options; |
82 | } |
83 | } |