1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Module\Plugin;
13:
14: use Xoops\Core\Kernel\Handlers\XoopsModule;
15:
16: /**
17: * Facilitates adding configuration requirements for a plugin to the configuration array for
18: * a consuming module.
19: *
20: * This is used for the argument for the event 'system.module.update.configs', and the listeners,
21: * presumably plugin providers, can access module details and add to the configuration as needed.
22: *
23: * @copyright 2013-2015 XOOPS Project (http://xoops.org)
24: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
25: * @author Richard Griffith <richard@geekwright.com>
26: */
27: class ConfigCollector
28: {
29: public $module;
30:
31: public $configs;
32:
33: /**
34: * __construct
35: *
36: * @param XoopsModule $module consuming module being installed
37: * @param array $configs configuration array for the consuming module
38: */
39: public function __construct(XoopsModule $module, &$configs)
40: {
41: $this->module = $module;
42: $this->configs = &$configs;
43: }
44:
45: public function add($pluginConfigs)
46: {
47: if (is_array($pluginConfigs) && !empty($pluginConfigs)) {
48: foreach ($pluginConfigs as $config) {
49: $this->configs[] = $config;
50: }
51: }
52: }
53:
54: public function module()
55: {
56: return $this->module;
57: }
58: }
59: