dolibarr 21.0.0-beta
DolConfigCollector.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25use DebugBar\DataCollector\ConfigCollector;
26
31class DolConfigCollector extends ConfigCollector
32{
38 public function getWidgets()
39 {
40 global $langs;
41
42 return array(
43 $langs->transnoentities('Config') => array(
44 "icon" => "gear",
45 "widget" => "PhpDebugBar.Widgets.VariableListWidget",
46 "map" => $this->getName(),
47 "default" => "{}"
48 )
49 );
50 }
51
57 public function collect()
58 {
59 $this->data = $this->getConfig();
60
61 return parent::collect();
62 }
63
69 protected function getConfig()
70 {
71 global $conf, $user;
72
73 // Get constants
74 $const = get_defined_constants(true);
75
76 $config = array(
77 'Dolibarr' => array(
78 'const' => $const['user'],
79 '$conf' => $this->objectToArray($conf),
80 '$user' => $this->objectToArray($user)
81 ),
82 'PHP' => array(
83 'version' => PHP_VERSION,
84 'interface' => PHP_SAPI,
85 'os' => PHP_OS
86 )
87 );
88
89 return $config;
90 }
91
92 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
99 protected function objectToArray($obj)
100 {
101 // phpcs:enable
102 $arr = array();
103 $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
104 foreach ($_arr as $key => $val) {
105 $val = (is_array($val) || is_object($val)) ? $this->objectToArray($val) : $val;
106 $arr[$key] = $val;
107 }
108
109 return $arr;
110 }
111}
DolConfigCollector class.
collect()
Return collected data.
getWidgets()
Return widget settings.
objectToArray($obj)
Convert an object to array.
getConfig()
Returns an array with config data.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79