Commit 1026b9da by Daniel Schmidt

Tabs vs. spaces

parent 00785d38
......@@ -18,29 +18,29 @@ use yii\helpers\Json;
*/
class JsonParser implements RequestParserInterface
{
/**
* @var boolean whether to return objects in terms of associative arrays.
*/
public $asArray = true;
/**
* @var boolean whether to return objects in terms of associative arrays.
*/
public $asArray = true;
/**
* @var boolean whether to throw an exception if the body is invalid json
*/
public $throwException = false;
/**
* @var boolean whether to throw an exception if the body is invalid json
*/
public $throwException = false;
/**
* @param string $rawBody the raw HTTP request body
* @return array parameters parsed from the request body
*/
/**
* @param string $rawBody the raw HTTP request body
* @return array parameters parsed from the request body
*/
public function parse($rawBody)
{
try {
return Json::encode($rawBody, $this->asArray);
} catch (InvalidParamException $e) {
if ($this->throwException) {
throw $e;
}
return null;
}
}
{
try {
return Json::encode($rawBody, $this->asArray);
} catch (InvalidParamException $e) {
if ($this->throwException) {
throw $e;
}
return null;
}
}
}
......@@ -128,13 +128,13 @@ class Request extends \yii\base\Request
* @see getRestParams()
*/
public $restVar = '_method';
/**
* @var array the parsers for converting the raw request body into [[restParams]]
* The array keys are the request content-types, and the array values are the
* corresponding configurations for creating the parser objects.
* @see getRestParams()
*/
public $parsers = [];
/**
* @var array the parsers for converting the raw request body into [[restParams]]
* The array keys are the request content-types, and the array values are the
* corresponding configurations for creating the parser objects.
* @see getRestParams()
*/
public $parsers = [];
private $_cookies;
......@@ -266,10 +266,10 @@ class Request extends \yii\base\Request
$this->_restParams = $_POST;
} else if (isset($this->parsers[$this->getContentType()])) {
$parser = Yii::createObject($this->parsers[$this->getContentType()]);
if (! $parser instanceof RequestParserInterface) {
throw new InvalidConfigException("The '{$this->contentType}' request parser is invalid. It must implement the RequestParserInterface.");
}
$this->_restParams = $parser->parse($this->getRawBody());
if (! $parser instanceof RequestParserInterface) {
throw new InvalidConfigException("The '{$this->contentType}' request parser is invalid. It must implement the RequestParserInterface.");
}
$this->_restParams = $parser->parse($this->getRawBody());
} else {
$this->_restParams = [];
mb_parse_str($this->getRawBody(), $this->_restParams);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment