PDA

View Full Version : Modifying MVC loading behavior



1099511627776
9 May 2012, 3:15 AM
Hello guys,
I was wandering if there is any way to modify the default behavior of class loading in MVC appliation.
For example I have an application with many controllers (models and stores). They are placed in corresponding folders like this:


- app
- controller
* controller1
* controller2
* controller3
- model
* model1
* model2
* model3
- store
* store1
* store2
* store3
- view
* view1
* view2
* view3

Now when I want to make a 4-th logical element I need to place controller4, model4 store4 and view4 in corresponding folders.
How can I reorder folders so thay would look like this:


- app
- logical_elem1
- controller
* controller1
- model
* model1
- store
* store1
- view
* view1

- logical_elem2
- controller
* controller2
- model
* model2
- store
* store2
- view
* view2

- logical_elem3
- controller
* controller3
- model
* model3
- store
* store3
- view
* view3

In this example it wolud be much more efficient to extend the application with new logical elements

1099511627776
9 May 2012, 10:19 PM
Anyone has any idea?
So far I've thought of somethng like redefining the Ext.Application method getModuleClassName with something like this:


getModuleClassName: function(name, type) {
if(name.indexOf('__.') == 0 ) {
return this.name + '.' + name.substring(name.indexOf('__.')+3) + '.' + type;
} else {
this.callParent(arguments);
}
}


But seems that this way works well with controllers but not mith multiple models and stores that are linked with curresponding logical element

redraid
11 May 2012, 1:28 AM
https://github.com/mitchellsimoens/SubAppDemo