[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Part of the Joomla Framework Input Package 4 * 5 * @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE 7 */ 8 9 namespace Joomla\Input; 10 11 /** 12 * Joomla! Input JSON Class 13 * 14 * This class decodes a JSON string from the raw request data and makes it available via the standard Input interface. 15 * 16 * @since 1.0 17 */ 18 class Json extends Input 19 { 20 /** 21 * The raw JSON string from the request. 22 * 23 * @var string 24 * @since 1.0 25 */ 26 private $raw; 27 28 /** 29 * Constructor. 30 * 31 * @param array|null $source Source data (Optional, default is the raw HTTP input decoded from JSON) 32 * @param array $options Array of configuration parameters (Optional) 33 * 34 * @since 1.0 35 */ 36 public function __construct($source = null, array $options = []) 37 { 38 if ($source === null) 39 { 40 $this->raw = file_get_contents('php://input'); 41 42 // This is a workaround for where php://input has already been read. 43 // See note under php://input on https://www.php.net/manual/en/wrappers.php.php 44 if (empty($this->raw) && isset($GLOBALS['HTTP_RAW_POST_DATA'])) 45 { 46 $this->raw = $GLOBALS['HTTP_RAW_POST_DATA']; 47 } 48 49 $source = json_decode($this->raw, true); 50 51 if (!\is_array($source)) 52 { 53 $source = []; 54 } 55 } 56 57 parent::__construct($source, $options); 58 } 59 60 /** 61 * Gets the raw JSON string from the request. 62 * 63 * @return string The raw JSON string from the request. 64 * 65 * @since 1.0 66 */ 67 public function getRaw() 68 { 69 return $this->raw; 70 } 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |