[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Input/ -> Json.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Input;
  11  
  12  use Joomla\CMS\Filter\InputFilter;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Joomla! Input JSON Class
  20   *
  21   * This class decodes a JSON string from the raw request data and makes it available via
  22   * the standard JInput interface.
  23   *
  24   * @since       3.0.1
  25   * @deprecated  5.0  Use Joomla\Input\Json instead
  26   */
  27  class Json extends Input
  28  {
  29      /**
  30       * @var    string  The raw JSON string from the request.
  31       * @since  3.0.1
  32       * @deprecated  5.0  Use Joomla\Input\Json instead
  33       */
  34      private $_raw;
  35  
  36      /**
  37       * Constructor.
  38       *
  39       * @param   array  $source   Source data (Optional, default is the raw HTTP input decoded from JSON)
  40       * @param   array  $options  Array of configuration parameters (Optional)
  41       *
  42       * @since   3.0.1
  43       * @deprecated  5.0  Use Joomla\Input\Json instead
  44       */
  45      public function __construct(array $source = null, array $options = array())
  46      {
  47          if (isset($options['filter'])) {
  48              $this->filter = $options['filter'];
  49          } else {
  50              $this->filter = InputFilter::getInstance();
  51          }
  52  
  53          if (\is_null($source)) {
  54              $this->_raw = file_get_contents('php://input');
  55              $this->data = json_decode($this->_raw, true);
  56  
  57              if (!is_array($this->data)) {
  58                  $this->data = array();
  59              }
  60          } else {
  61              $this->data = &$source;
  62          }
  63  
  64          $this->options = $options;
  65      }
  66  
  67      /**
  68       * Gets the raw JSON string from the request.
  69       *
  70       * @return  string  The raw JSON string from the request.
  71       *
  72       * @since   3.0.1
  73       * @deprecated  5.0  Use Joomla\Input\Json instead
  74       */
  75      public function getRaw()
  76      {
  77          return $this->_raw;
  78      }
  79  }


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