The exception is right, only scalar/null values are allowed to pass for controller attributes when render_hinclude()
is used, because is needed to generate a valid fragment URI from them.
Why?
Suppose you try to pass this entity with private properties, when it comes to generate the URI for this parameter happens the following:
var_dump(http_build_query(array('object' => $my_object)))
// output:
// string(0) ""
http://php.net/manual/en/function.http-build-query.php#refsect1-function.http-build-query-parameters
If query_data
is an object, then only public properties will be incorporated into the result.
BTW the statement that you provided is not valid, you should pass this attribute to controller(...)
function, something like this:
{{ render_hinclude(controller("AppBundle:Default:test", {'id': my_object.id })) }}
Then, your controller should have the scalar value id
and get the corresponding object. However, use the argument resolver feature to avoid this step:
public function testAction(Object $object) {...}
Next:
{{ render_hinclude(controller("AppBundle:Default:test", {'object': my_object.id })) }}