CoreFiles by mySites.guru
SessionCollector.php80 lines, 1,732 bytes, from Joomla_4.2.0-Stable-Full_Package.zip
Raw History Compare with 4.1.5
md5
05909b21169fe6ff43028c6844d4728d
sha1
7f1dfb3c24902928e1373dcc931bee9c3a4fa67b
sha256
2d4bba32497cb9a86f7f55a73451da8d363e9b231deef005b23ed5008c329970
<?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;

/**
 * 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 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.