CoreFiles by mySites.guru
SessionCollector.php84 lines, 1,839 bytes, from Joomla_4.2.3-Stable-Full_Package.zip
Raw History Compare with 4.2.2
md5
0d43a7952ede1394b89423331c659d95
sha1
58814f9b1dbda8154f4d50f52f92bc86608282fe
sha256
cafd582352de307056bf9bf33a96d4e0af373c8df2a92281044c373ee80a0c6c
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  System.Debug
 *
 * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Plugin\System\Debug\DataCollector;

use Joomla\CMS\Factory;
use Joomla\Plugin\System\Debug\AbstractDataCollector;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * SessionDataCollector
 *
 * @since  4.0.0
 */
class SessionCollector extends AbstractDataCollector
{
    /**
     * Collector name.
     *
     * @var   string
     * @since 4.0.0
     */
    private $name = 'session';

    /**
     * Called by the DebugBar when data needs to be collected
     *
     * @since  4.0.0
     *
     * @return array Collected data
     */
    public function collect()
    {
        $data = [];

        foreach (Factory::getApplication()->getSession()->all() as $key => $value) {
            $data[$key] = $this->getDataFormatter()->formatVar($value);
        }

        return ['data' => $data];
    }

    /**
     * Returns the unique name of the collector
     *
     * @since  4.0.0
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Returns a hash where keys are control names and their values
     * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()}
     *
     * @since  4.0.0
     *
     * @return array
     */
    public function getWidgets()
    {
        return [
            'session' => [
                'icon' => 'key',
                'widget' => 'PhpDebugBar.Widgets.VariableListWidget',
                'map' => $this->name . '.data',
                'default' => '[]',
            ],
        ];
    }
}

The same content is in 4 releases, Joomla 4.2.1 to 4.2.3. See them all, or every version of this file.