本文整理汇总了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);
}
//.........这里部分代码省略.........