Reputation: 21
How do i get an request_vars from RestRequest Object..i want all the fields from an array.Below is the mentioned code
RestRequest Object
(
[request_vars:RestRequest:private] => Array
(
[{
"taskStmt":"demoo",
"description":"",
"projectId":"",
"assignedDate":"",
"endDate":"",
"TaskEffort":"",
"estimateTime":"",
"dependencies":_"",
"priority":"",
"timeTaken":"",
"workCompletion":"",
"status":"",
"user_id":"",
"mailsent":"",
"completiondate":""
}
] =>
)
[data:RestRequest:private] =>
[http_accept:RestRequest:private] => json
[method:RestRequest:private] => put
)
Upvotes: 2
Views: 113
Reputation: 20753
The examples you posted in comment have a getRequestVars()
method on the class RestRequest
, that should return those values.
You can get around visibility modifiers like protected
and private
with Reflection if you must, but probably not a good idea:
class Foo {
public $foo = 1;
protected $bar = 2;
private $baz = 3;
}
$foo = new Foo();
$reflect = new ReflectionClass($foo);
$props = $reflect->getProperties();
foreach ($props as $prop) {
$prop->setAccessible(true);
print $prop->getName().' = '.$prop->getValue($foo)."\n";
}
Upvotes: 1
Reputation: 27130
According to your dump, request_vars is a private and no-static attribute.
So you need a getter method like this:
class RestRequest
{
// ...
public function getRequestVars()
{
return $this->request_vars;
}
}
In this way you cannot edit/write the value of request_vars directly, but you can read it through the getRequestVars() public method:
var_dump( $object->getRequestVars() );
Upvotes: 2