Sugar needs to add Simpleness to the MVC framework
Just spraying out some thoughts just after fixing a custom view with a custom action name is a default module..
The action that I have is FullTextSearch. This is camelcase, because it's Sugar's convention. Fine. But now, I want to create a custom view, which needs to be called ./custom/modules/views/view.fulltextsearch.php>, because of:
<?php
class ViewFactory{
function loadView($type = 'default', $module, $bean = null, $view_object_map = array()){
----> $type = strtolower($type);
?>Wait a minute. This is complicated, because in the old way, I needed to make an action file in ./custom/modules/ named exactly like the action I'm creating. Weird!
But now, I want to fill my new view.fulltextsearch.php. And it won't work. I'm looking at examples, and it won't work. Why? Because of this piece of code:
<?php
/**
* This is a private function which just helps the getView function generate the
* proper view object
*
* @return a valid SugarView
*/
function _buildFromFile($file, &$bean, $view_object_map, $type, $module){
require_once($file);
//try ModuleViewType first then try ViewType if that fails then use SugarView
$class = ucfirst($module).'View'.ucfirst($type);
if(!class_exists($class)){
$class = 'View'.ucfirst($type);
if(!class_exists($class)){
return new SugarView($bean, $view_object_map);
}
}
return ViewFactory::_buildClass($class, $bean, $view_object_map);
}
?>Well, this actually says I need to rename my class+constructor to DocumentsViewFulltextsearch.
So, my file needs to begin with "view.", while it's in /views/ already (and there are only view files in it), and my class needs to be named DocumentsViewFulltextsearch, because of the last code piece above.
This just adds complexity, and I wish someone would architect these kind of changes in the future.
- Topic:
