[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/debug/src/DataCollector/ -> SessionCollector.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  System.Debug
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Plugin\System\Debug\DataCollector;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\Plugin\System\Debug\AbstractDataCollector;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * SessionDataCollector
  22   *
  23   * @since  4.0.0
  24   */
  25  class SessionCollector extends AbstractDataCollector
  26  {
  27      /**
  28       * Collector name.
  29       *
  30       * @var   string
  31       * @since 4.0.0
  32       */
  33      private $name = 'session';
  34  
  35      /**
  36       * Called by the DebugBar when data needs to be collected
  37       *
  38       * @since  4.0.0
  39       *
  40       * @return array Collected data
  41       */
  42      public function collect()
  43      {
  44          $data = [];
  45  
  46          foreach (Factory::getApplication()->getSession()->all() as $key => $value) {
  47              $data[$key] = $this->getDataFormatter()->formatVar($value);
  48          }
  49  
  50          return ['data' => $data];
  51      }
  52  
  53      /**
  54       * Returns the unique name of the collector
  55       *
  56       * @since  4.0.0
  57       *
  58       * @return string
  59       */
  60      public function getName()
  61      {
  62          return $this->name;
  63      }
  64  
  65      /**
  66       * Returns a hash where keys are control names and their values
  67       * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()}
  68       *
  69       * @since  4.0.0
  70       *
  71       * @return array
  72       */
  73      public function getWidgets()
  74      {
  75          return [
  76              'session' => [
  77                  'icon' => 'key',
  78                  'widget' => 'PhpDebugBar.Widgets.VariableListWidget',
  79                  'map' => $this->name . '.data',
  80                  'default' => '[]',
  81              ],
  82          ];
  83      }
  84  }


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