[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/maximebf/debugbar/src/DebugBar/DataCollector/ -> ConfigCollector.php (source)

   1  <?php
   2  /*
   3   * This file is part of the DebugBar package.
   4   *
   5   * (c) 2013 Maxime Bouroumeau-Fuseau
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  namespace DebugBar\DataCollector;
  12  
  13  /**
  14   * Collects array data
  15   */
  16  class ConfigCollector extends DataCollector implements Renderable, AssetProvider
  17  {
  18      protected $name;
  19  
  20      protected $data;
  21  
  22      // The HTML var dumper requires debug bar users to support the new inline assets, which not all
  23      // may support yet - so return false by default for now.
  24      protected $useHtmlVarDumper = false;
  25  
  26      /**
  27       * Sets a flag indicating whether the Symfony HtmlDumper will be used to dump variables for
  28       * rich variable rendering.
  29       *
  30       * @param bool $value
  31       * @return $this
  32       */
  33      public function useHtmlVarDumper($value = true)
  34      {
  35          $this->useHtmlVarDumper = $value;
  36          return $this;
  37      }
  38  
  39      /**
  40       * Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
  41       * rendering.
  42       *
  43       * @return mixed
  44       */
  45      public function isHtmlVarDumperUsed()
  46      {
  47          return $this->useHtmlVarDumper;
  48      }
  49  
  50      /**
  51       * @param array  $data
  52       * @param string $name
  53       */
  54      public function __construct(array $data = array(), $name = 'config')
  55      {
  56          $this->name = $name;
  57          $this->data = $data;
  58      }
  59  
  60      /**
  61       * Sets the data
  62       *
  63       * @param array $data
  64       */
  65      public function setData(array $data)
  66      {
  67          $this->data = $data;
  68      }
  69  
  70      /**
  71       * @return array
  72       */
  73      public function collect()
  74      {
  75          $data = array();
  76          foreach ($this->data as $k => $v) {
  77              if ($this->isHtmlVarDumperUsed()) {
  78                  $v = $this->getVarDumper()->renderVar($v);
  79              } else if (!is_string($v)) {
  80                  $v = $this->getDataFormatter()->formatVar($v);
  81              }
  82              $data[$k] = $v;
  83          }
  84          return $data;
  85      }
  86  
  87      /**
  88       * @return string
  89       */
  90      public function getName()
  91      {
  92          return $this->name;
  93      }
  94  
  95      /**
  96       * @return array
  97       */
  98      public function getAssets() {
  99          return $this->isHtmlVarDumperUsed() ? $this->getVarDumper()->getAssets() : array();
 100      }
 101  
 102      /**
 103       * @return array
 104       */
 105      public function getWidgets()
 106      {
 107          $name = $this->getName();
 108          $widget = $this->isHtmlVarDumperUsed()
 109              ? "PhpDebugBar.Widgets.HtmlVariableListWidget"
 110              : "PhpDebugBar.Widgets.VariableListWidget";
 111          return array(
 112              "$name" => array(
 113                  "icon" => "gear",
 114                  "widget" => $widget,
 115                  "map" => "$name",
 116                  "default" => "{}"
 117              )
 118          );
 119      }
 120  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer