Hi guys, I have a problem with getRestParams method
Look at CHttpRequest
public function getRestParams()
{
if($this->_restParams===null)
{
$result=array();
if(function_exists('mb_parse_str'))
mb_parse_str($this->getRawBody(), $result);
else
parse_str($this->getRawBody(), $result);
$this->_restParams=$result;
}
return $this->_restParams;
}
But what about JSON encoded data. For example Backbone JS likes to send JSON encoded data. Of course I can change dataType on client side but the issue still exists. So I assume to get such method
public function getRestParams()
{
if($this->_restParams===null) {
$result=array();
if ($_SERVER['CONTENT_TYPE'] == 'application/json') {
$result = \CJSON::decode($this->getRawBody());
} else {
if(function_exists('mb_parse_str')) {
mb_parse_str($this->getRawBody(), $result);
} else {
parse_str($this->getRawBody(), $result);
}
}
$this->_restParams=$result;
}
return $this->_restParams;
}
And again I could override CHttpRequest but $_restParams is private. For now I have to override also getDelete and getPut methods in order to make it works.
What you think about this issue.