Hi people
I just filed a new feature on Bug Tracker: 32271 - Make views more extendeable
This feature enable any developer to extend any views and also avoiding coping all code from extended view.
Let me explain in details.
In the file include/MVC/View/ViewFactory.php SugarCRM decide which view file needs to be loaded.
The sequence of choice:
'custom/modules/'.$module.'/views/view.'.$type.'.php' (class is $module . 'View' . ucfirst($type))
'modules/'.$module.'/views/view.'.$type.'.php' (class is $module . 'View' . ucfirst($type))
'custom/include/MVC/View/views/view.'.$type.'.php' (class is 'View' . ucfirst($type))
'include/MVC/View/views/view.'.$type.'.php' (class is 'View' . ucfirst($type))
According to current strategy Sugar does try to instantiate the same class for choices 1 and 2, and also for choices 3 and 4, what obligate you to copy all code from extended view and set into new view.
The proposed fix try to instantiate object from classes whose name is according to file to be loaded:
custom/modules/Accounts/views/view.detail.php: view class is CustomAccountsViewDetail
modules/Accounts/views/view.detail.php: view class is AccountsViewDetail
custom/include/MVC/View/views/view.edit.php: view class is CustomViewEdit
include/MVC/View/views/view.edit.php: view class is ViewEdit
This way you can only override the method to be modified and invokes the parent method.
I can see two benefits on this strategy:
Override only the necessary code;
Reduce issues when upgrading a system whose views had been customized.
I just did the same for Controller.
Best regards


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks