Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
37.50% covered (danger)
37.50%
3 / 8
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
PluginManager
37.50% covered (danger)
37.50%
3 / 8
66.67% covered (warning)
66.67%
2 / 3
5.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 validate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 reload
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * VuFind Config Manager
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  ServiceManager
25 * @author   Demian Katz <demian.katz@villanova.edu>
26 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27 * @link     https://vufind.org/wiki/development Wiki
28 */
29
30namespace VuFind\Config;
31
32use Laminas\ServiceManager\AbstractPluginManager as Base;
33
34/**
35 * VuFind Config Manager
36 *
37 * @category VuFind
38 * @package  ServiceManager
39 * @author   Demian Katz <demian.katz@villanova.edu>
40 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
41 * @link     https://vufind.org/wiki/development Wiki
42 */
43class PluginManager extends Base
44{
45    /**
46     * Constructor
47     *
48     * Make sure plugins are properly initialized.
49     *
50     * @param mixed $configOrContainerInstance Configuration or container instance
51     * @param array $v3config                  If $configOrContainerInstance is a
52     * container, this value will be passed to the parent constructor.
53     */
54    public function __construct(
55        $configOrContainerInstance = null,
56        array $v3config = []
57    ) {
58        $this->addAbstractFactory(PluginFactory::class);
59        parent::__construct($configOrContainerInstance, $v3config);
60    }
61
62    /**
63     * Validate the plugin
64     *
65     * Checks that the filter loaded is either a valid callback or an instance
66     * of FilterInterface.
67     *
68     * @param mixed $plugin Plugin to validate
69     *
70     * @return void
71     *
72     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
73     */
74    public function validate($plugin)
75    {
76        // Assume everything is okay.
77    }
78
79    /**
80     * Reload a configuration and return the new version
81     *
82     * @param string $id Service identifier
83     *
84     * @return \Laminas\Config\Config
85     */
86    public function reload($id)
87    {
88        $oldOverrideSetting = $this->getAllowOverride();
89        $this->setAllowOverride(true);
90        $this->setService($id, $this->build($id));
91        $this->setAllowOverride($oldOverrideSetting);
92        return $this->get($id);
93    }
94}