CoreFiles by mySites.guru
SessionCollector.php80 lines, 1,506 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
4ada57b01e291b70ab9e4412acbebef7
sha1
f9e839a4e0b0b086a29a7c7c8fd325f0d6dd123a
sha256
98c0ecef0f77b7e48cc7e70124d6391a5890b61eba4ee298b0fcc49eb12211b9
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  System.Debug
 *
 * @copyright   Copyright (C) 2017 Open Source Matters, Inc. All rights reserved.
 * @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.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.