dolibarr  17.0.4
DolConfigCollector.php
1 <?php
2 
3 use \DebugBar\DataCollector\ConfigCollector;
4 
9 class DolConfigCollector extends ConfigCollector
10 {
16  public function getWidgets()
17  {
18  global $langs;
19 
20  return array(
21  $langs->transnoentities('Config') => array(
22  "icon" => "gear",
23  "widget" => "PhpDebugBar.Widgets.VariableListWidget",
24  "map" => $this->getName(),
25  "default" => "{}"
26  )
27  );
28  }
29 
35  public function collect()
36  {
37  $this->data = $this->getConfig();
38 
39  return parent::collect();
40  }
41 
47  protected function getConfig()
48  {
49  global $conf, $user;
50 
51  // Get constants
52  $const = get_defined_constants(true);
53 
54  $config = array(
55  'Dolibarr' => array(
56  'const' => $const['user'],
57  '$conf' => $this->objectToArray($conf),
58  '$user' => $this->objectToArray($user)
59  ),
60  'PHP' => array(
61  'version' => PHP_VERSION,
62  'interface' => PHP_SAPI,
63  'os' => PHP_OS
64  )
65  );
66 
67  return $config;
68  }
69 
70  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
77  protected function objectToArray($obj)
78  {
79  // phpcs:enable
80  $arr = array();
81  $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
82  foreach ($_arr as $key => $val) {
83  $val = (is_array($val) || is_object($val)) ? $this->objectToArray($val) : $val;
84  $arr[$key] = $val;
85  }
86 
87  return $arr;
88  }
89 }
DolConfigCollector class.
collect()
Return collected data.
getWidgets()
Return widget settings.
objectToArray($obj)
Convert an object to array.
getConfig()
Returns an array with config data.