Symfony : Single view for multiple models
I am developing a project in symfony.
In my DB I have a set of models (tables) for each geography. Each set of models is presented to user in same way. So, th开发者_StackOverflowe view should be same for each geography.
I want to have single view for each set of models. So, is it possible to dynamically associate a model to a request based on the context of the request? If this is possible then I will need a single module and hence I will be able to avoid duplicate modules with same view and different models.
Thanks.
In MVC model is NOT tied to a view. Controller uses model to retrieve the data and passes it to the view.
You didn't describe your model in details but it looks like you could use table inheritance or Doctrine's behaviors (either existing Geographical behavior or your custom one).
You can also use completely different model classes in the same way as long as they support the same interface. You could use PHP interface to ensure your model's used in the right way.
精彩评论