本文整理汇总了PHP中SugarBean::inOperation方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::inOperation方法的具体用法?PHP SugarBean::inOperation怎么用?PHP SugarBean::inOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarBean
的用法示例。
在下文中一共展示了SugarBean::inOperation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRelatedName
/**
* @param ForecastWorksheet $bean
* @param string $event
* @param array $args
* @return bool
*/
public static function checkRelatedName($bean, $event, $args)
{
if ($event == 'before_save') {
if (empty($bean->account_id) && !empty($bean->account_name)) {
$bean->account_name = '';
}
if (empty($bean->opportunity_id) && !empty($bean->opportunity_name)) {
$bean->opportunity_name = '';
}
// if we are in a delete operation, don't update the date modified
if (isset($bean->fetched_row['date_modified']) && (SugarBean::inOperation('delete') || SugarBean::inOperation('saving_related'))) {
$bean->date_modified = $bean->fetched_row['date_modified'];
}
}
return true;
}
示例2: createOrUpdate
/**
* Handler for create and update actions on a bean.
*
* @param SugarBean $bean
* @param array $args
* @param Activity $act
* @return bool eventProcessed
*/
protected function createOrUpdate(SugarBean $bean, array $args, Activity $act)
{
if ($bean->deleted || $bean->inOperation('saving_related')) {
return false;
}
// Add Appropriate Subscriptions for this Bean
$this->addRecordSubscriptions($args, $bean);
$data = array('object' => self::getBeanAttributes($bean));
if ($args['isUpdate']) {
$act->activity_type = 'update';
$data['changes'] = $args['dataChanges'];
$this->prepareChanges($bean, $data);
//if no field changes to report, do not create the activity
if (empty($data['changes'])) {
return false;
}
} else {
$act->activity_type = 'create';
}
$act->parent_id = $bean->id;
$act->parent_type = $bean->module_name;
$act->data = $data;
$act->save();
$act->processRecord($bean);
return true;
}
示例3: getLinkField
protected function getLinkField($fieldName)
{
if ((empty($this->context->{$fieldName}) || !is_a($this->context->{$fieldName}, "Link2")) && !$this->context->load_relationship($fieldName)) {
throw new Exception("Unable to load relationship {$fieldName}");
}
if (empty($this->context->{$fieldName})) {
throw new Exception("Relationship {$fieldName} was not set");
}
if (SugarBean::inOperation('delete')) {
// if we are in a delete operation, always re-fetch the relationships beans
// as one of the could have changed and we want the freshest set from the db
$this->context->{$fieldName}->beans = null;
$this->context->{$fieldName}->resetLoaded();
} elseif (isset($this->context->{$fieldName}->beans)) {
return $this->context->{$fieldName}->beans;
}
$beans = $this->context->{$fieldName}->getBeans();
return $beans;
}