In my Symfony2 project, I have a ModelBundle which holds my entities, and other bundles for the frontend, backend, etc, which utilise that ModelBundle.
I have a couple of model-specific functions that perform some entity-specific tasks. Where do I put these?
- Do I create a seperate 'model' folder next to my Entity folder, and put all those functions in there?
- Do I create a controller in my 'ModelBundle' that holds these functions as actions? This might be weird, since controllers, in my mind, take HTTP requests and return an HTTP response, so it's not applicable in this context.
- Do I put them inside the entity classes themselves? Is this nice? And is there a chance that they are over-written when I re-generate my ORM?
- Am I looking for custom repositories? I can make those and put them into a 'model' folder or something. http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#custom-repositories
P.S.: I love Symfony2, but I will be very happy when everyone has a defined set of best practices for the framework :-)