I have been very puzzled about the concept of model (entity) persistence in Symfony2. AFAIK, there is nothing like model_instance->save() in Symfony2. Instead, it must be invoked in a controller by retrieving the doctrine entity manager, and then persist the model_instance and flush the model_instance.
- If I have a Blog model, which contains variable Tag model instances and Category model instances, which will be generated from the blog message body. However, I do not know how I can create a Blog factory to also save these tags and categories, instead I must return these "Tag" and "Category" instances from a factory (which it won't persist anyway) --- there is no way I can persist the blog and persist the tags and categories all within a single method in the Blog.
In fact, if I want to write a script that is invoked periodically to persist models, it seems impossible, because it must invoke the controller, and yet I don't see why a script requires a web server to be present, but not just work on the object model without touching the web server.
I really appreciate how to resolve the problems above. Thank you!