Пример #1
0
 public function test_buildClass()
 {
     //checck with valid values and test if it returns correct view instance
     $view = ViewFactory::_buildClass('UsersViewList', null, array());
     $this->assertInstanceOf('UsersViewList', $view);
     //checck with valid values and test if it returns correct view instance
     $view = ViewFactory::_buildClass('UsersViewDetail', null, array());
     $this->assertInstanceOf('UsersViewDetail', $view);
 }
Пример #2
0
 /**
  * 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);
     $customClass = 'Custom' . $class;
     if (class_exists($customClass)) {
         return ViewFactory::_buildClass($customClass, $bean, $view_object_map);
     }
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now try the next set of possibilites if it was none of the above
     $class = 'View' . ucfirst($type);
     $customClass = 'Custom' . $class;
     if (class_exists($customClass)) {
         return ViewFactory::_buildClass($customClass, $bean, $view_object_map);
     }
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now check if there is a custom SugarView for generic handling
     if (file_exists('custom/include/MVC/View/SugarView.php')) {
         require_once 'custom/include/MVC/View/SugarView.php';
         if (class_exists('CustomSugarView')) {
             return new CustomSugarView($bean, $view_object_map);
         }
     }
     //if all else fails return SugarView
     return new SugarView($bean, $view_object_map);
 }
Пример #3
0
 /**
  * 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 = SugarAutoLoader::customClass(ucfirst($module) . 'View' . ucfirst($type));
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now try the next set of possibilites if it was none of the above
     //It can be expensive to load classes this way so it's not recommended
     $class = SugarAutoLoader::customClass('View' . ucfirst($type));
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now check if there is a custom SugarView for generic handling
     // autoloader will check filesystem
     $class = SugarAutoLoader::customClass('SugarView', true);
     //if all else fails return SugarView
     return new $class($bean, $view_object_map);
 }
 /**
  * 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);
 }