tags:

views:

18

answers:

1

Hi,

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, the 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.

+2  A: 

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.

kuba
Thanks. Yes. I think inheritance could be easy method. I now understand that symfony does not provide any built-in mechanism to support this functionality.
LionHeart
@benlumley suggested good thing. You could write your own routing class which would retrieve object of any class you want to support. I still think it would be the best if all those classes implement the same interface.
kuba