本文整理汇总了PHP中Opportunity::getFieldDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::getFieldDefinition方法的具体用法?PHP Opportunity::getFieldDefinition怎么用?PHP Opportunity::getFieldDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opportunity
的用法示例。
在下文中一共展示了Opportunity::getFieldDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFields
/**
* Process the field vardefs as setup by the extending classes
*/
protected function processFields()
{
// get the get_widget helper and the StandardField Helper
SugarAutoLoader::load('modules/DynamicFields/FieldCases.php');
SugarAutoLoader::load('modules/ModuleBuilder/parsers/StandardField.php');
foreach ($this->field_vardef_setup as $field => $new_defs) {
// get the field defs
$field_defs = $this->bean->getFieldDefinition($field);
// load the field type up
$f = get_widget($field_defs['type']);
$diff = array();
foreach ($new_defs as $k => $v) {
if (!isset($field_defs[$k])) {
switch ($k) {
case 'massupdate':
case 'studio':
case 'reportable':
case 'workflow':
if (!$v) {
$diff[$k] = $v;
}
break;
default:
if ($v) {
$diff[$k] = $v;
}
}
} elseif ($field_defs[$k] != $v) {
$diff[$k] = $v;
}
}
if (empty($diff)) {
continue;
}
// populate the row from the vardefs that were loaded and the new_defs
$f->populateFromRow(array_merge($field_defs, $diff));
// now lets save, since these are OOB field, we use StandardField
$df = new StandardField($this->bean->module_name);
$df->setup($this->bean);
$f->module = $this->bean;
// StandardField considers only the attributes which can be edited in Studio,
// while the "studio" attribute is not one of them. we need to change the vardef map temporarily here,
// because changing it permanently will make the "studio" attribute always overridden with empty value,
// after the field has been saved in Studio
if (!isset($f->vardef_map['studio'])) {
$f->vardef_map['studio'] = 'studio';
}
$f->save($df);
}
}
示例2: processList
/**
* Process the ListView to set the fields correctly
*
* @param array $fieldMap
* @param $current_fields
* @param ListLayoutMetaDataParser $listParser
*/
private function processList(array $fieldMap, $current_fields, ListLayoutMetaDataParser $listParser)
{
if (!$listParser instanceof SidecarListLayoutMetaDataParser) {
return false;
}
$handleSave = false;
$saveFields = array();
// process the fields
foreach ($current_fields as $panel_id => $panel) {
if (is_array($panel['fields'])) {
foreach ($panel['fields'] as $field) {
$name = $field['name'];
$addField = true;
$additionalDefs = $field;
if (isset($fieldMap[$name])) {
if ($fieldMap[$name] === true) {
// nothing to do, field is present
} elseif ($fieldMap[$name] !== false) {
// we have the field, so get it's defs
$defs = $this->bean->getFieldDefinition($fieldMap[$name]);
if ($defs) {
// set the name variable to the new field name.
$name = $fieldMap[$name];
// reset the additionDefs since we have a new field
$additionalDefs = array();
} else {
// we didn't find any defs for the new field, so error on caution and remove the old one
$addField = false;
}
$handleSave = true;
} else {
// instead of a name being passed in, false was, so we should remove that field.
$addField = false;
$handleSave = true;
}
unset($fieldMap[$name]);
}
if ($addField) {
$saveFields[] = array($name, $additionalDefs);
}
}
}
}
// make sure that the field map is empty, if it's not process any remaining fields
if (!empty($fieldMap)) {
foreach ($fieldMap as $field => $trigger) {
if ($trigger === true) {
$defs = $this->bean->getFieldDefinition($field);
if ($defs) {
$saveFields[] = array($field, array());
$handleSave = true;
}
}
}
}
if ($handleSave) {
// make sure the list is reset
$listParser->resetPanelFields();
foreach ($saveFields as $params) {
$listParser->addField($params[0], $params[1]);
}
$listParser->handleSave(false);
}
}