CoreFiles by mySites.guru
Json.php88 lines, 2,243 bytes, from Joomla_6.0.3-Stable-Full_Package.zip
Raw History Compare with 6.0.2
md5
0c4364bdf771f275cee0271df740b996
sha1
7e7ff4f6aa3437ba86e7c60c7cd12d055cf2fdf6
sha256
2c858c4701ed7355ec690e3941abb0c757730f104426fd8cd8ca2d38a88ca3f9
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Input;

use Joomla\CMS\Filter\InputFilter;

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

/**
 * Joomla! Input JSON Class
 *
 * This class decodes a JSON string from the raw request data and makes it available via
 * the standard JInput interface.
 *
 * @since       3.0.1
 *
 * @deprecated   4.3 will be removed in 6.0.
 *               Use Joomla\Input\Json instead
 */
class Json extends Input
{
    /**
     * @var    string  The raw JSON string from the request.
     * @since  3.0.1
     *
     * @deprecated   4.3 will be removed in 6.0.
     *               Use Joomla\Input\Json instead
     */
    // phpcs:ignore
    private $_raw;

    /**
     * Constructor.
     *
     * @param   array  $source   Source data (Optional, default is the raw HTTP input decoded from JSON)
     * @param   array  $options  Array of configuration parameters (Optional)
     *
     * @since   3.0.1
     *
     * @deprecated   4.3 will be removed in 6.0.
     *               Use Joomla\Input\Json instead
     */
    public function __construct(?array $source = null, array $options = [])
    {
        if (isset($options['filter'])) {
            $this->filter = $options['filter'];
        } else {
            $this->filter = InputFilter::getInstance();
        }

        if (\is_null($source)) {
            $this->_raw = file_get_contents('php://input');
            $this->data = json_decode($this->_raw, true);

            if (!\is_array($this->data)) {
                $this->data = [];
            }
        } else {
            $this->data = &$source;
        }

        $this->options = $options;
    }

    /**
     * Gets the raw JSON string from the request.
     *
     * @return  string  The raw JSON string from the request.
     *
     * @since   3.0.1
     *
     * @deprecated   4.3 will be removed in 6.0.
     *               Use Joomla\Input\Json instead
     */
    public function getRaw()
    {
        return $this->_raw;
    }
}

The same content is in 41 releases, Joomla 6.0.0-alpha1 to 6.2.0-alpha1. See them all, or every version of this file.