I'm trying to follow William Durand's tutorial here to create a rest api using fosrest bundle and propel. I've been beating my head against the serialization for 2 days now. I've found some users that ran into a similar problem, but have found no solution.
Here is my controller:
/**
* @Rest\View
*/
public function allAction(){
$messages = MessageQuery::create()->find();
return array('messages' => $messages);
}
I'm expecting an output of messages and ids, however I get an output with information about my model:
{ "messages" : { "formatter" : { "as_columns" : [ ],
"class" : "My\\FooBundle\\Model\\Message",
"collection_name" : "PropelObjectCollection",
"current_objects" : [ ],
"db_name" : "fooDB",
"has_limit" : false,
"peer" : "My\\FooBundle\\Model\\MessagePeer",
"with" : [ ]
},
"model" : "My\\FooBundle\\Model\\Message"
} }
I've ensured that my jmsserializer bundle has the propelcollectionhandler.php patch.
I have this in my app/config/config.yml
jms_serializer:
metadata:
auto_detection: true
directories:
Propel:
namespace_prefix: "My\\FooBundle\\Model\\om"
path: "@MyFooBundle/Resources/config/serializer"
I've seen that the namespace_prefix
is blank on some of the examples on Github, because they claim the BaseModel
in propel has no namespace, but my autogenerated propel base models have a namespace, is this something new in 1.7? I have tried it with and without a namespace_prefix
and I do have a Model.om.BaseTableMessage.yml
file in the specified directory.
Has anybody ran into this problem? How did you solve it? Thanks!