当前位置: 首页>>代码示例>>PHP>>正文


PHP SugarBean::_createBean方法代码示例

本文整理汇总了PHP中SugarBean::_createBean方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::_createBean方法的具体用法?PHP SugarBean::_createBean怎么用?PHP SugarBean::_createBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SugarBean的用法示例。


在下文中一共展示了SugarBean::_createBean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBean

 /**
  * Returns a SugarBean object by id. The Last 10 loaded beans are cached in memory to prevent multiple retrieves per request.
  * If no id is passed, a new bean is created.
  * @static
  * @param String $module
  * @param String $id
  * @param Array $params A name/value array of parameters. Names: encode, deleted,
  *        disable_row_level_security
  *        If $params is boolean we revert to the old arguments (encode, deleted), and use $params as $encode.
  *        This will be changed to using only $params in later versions.
  * @param Bool $deleted @see SugarBean::retrieve
  * @return SugarBean|null
  */
 public static function getBean($module, $id = null, $params = array(), $deleted = true)
 {
     // Check if params is an array, if not use old arguments
     if (isset($params) && !is_array($params)) {
         $params = array('encode' => $params);
     }
     // Pull values from $params array
     if (defined('ENTRY_POINT_TYPE') && constant('ENTRY_POINT_TYPE') == 'api') {
         // In API mode, we can cache all beans unless specifically told not
         // to retrieve a cached version.
         $encode = false;
         $can_cache = isset($params['use_cache']) ? $params['use_cache'] : true;
     } else {
         // In GUI mode, we will cache only encoded beans unless specifically
         // told not to retrieve a cached version.
         $encode = isset($params['encode']) ? $params['encode'] : true;
         $can_cache = isset($params['use_cache']) ? $params['use_cache'] && $encode : $encode;
     }
     $deleted = isset($params['deleted']) ? $params['deleted'] : $deleted;
     if (!isset(self::$loadedBeans[$module])) {
         self::$loadedBeans[$module] = array();
         self::$touched[$module] = array();
     }
     $beanClass = self::getBeanName($module);
     if (empty($beanClass) || !class_exists($beanClass)) {
         return null;
     }
     if (!empty($id)) {
         if (!$can_cache || empty(self::$loadedBeans[$module][$id])) {
             // $bean = new $beanClass();
             $bean = SugarBean::_createBean($beanClass);
             // Pro+ versions, to disable team check if we have rights
             // to change the parent bean, but not the related (e.g. change Account Name of Opportunity)
             if (!empty($params['disable_row_level_security'])) {
                 $bean->disable_row_level_security = true;
             }
             $result = $bean->retrieve($id, $encode, $deleted);
             if (empty($result)) {
                 if (empty($params['strict_retrieve'])) {
                     return $bean;
                 } else {
                     return null;
                 }
             } else {
                 if ($can_cache) {
                     self::registerBean($bean);
                 }
             }
         } else {
             $bean = self::$loadedBeans[$module][$id];
             // check if cached bean is deleted
             if ($deleted && !empty($bean->deleted)) {
                 if (empty($params['strict_retrieve'])) {
                     return SugarBean::_createBean($beanClass);
                 } else {
                     return null;
                 }
             }
             // cached bean was retrieved with team security disabled
             if (empty($params['disable_row_level_security']) && !empty($bean->disable_row_level_security)) {
                 $newBean = SugarBean::_createBean($beanClass);
                 if (isset($params['disable_row_level_security'])) {
                     // false
                     $newBean->disable_row_level_security = false;
                 }
                 if (empty($newBean->disable_row_level_security)) {
                     // retireve with team security enabled
                     $result = $newBean->retrieve($id, $encode, $deleted);
                     if (empty($result)) {
                         if (empty($params['strict_retrieve'])) {
                             return $bean;
                         } else {
                             return null;
                         }
                     } else {
                         // save new bean in cache
                         self::$loadedBeans[$module][$id] = $newBean;
                         return $newBean;
                     }
                 }
             }
             self::$hits++;
             self::$touched[$module][$id]++;
         }
     } else {
         $bean = SugarBean::_createBean($beanClass);
     }
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:BeanFactory.php


注:本文中的SugarBean::_createBean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。