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


PHP Opportunity::getFieldDefinition方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:53,代码来源:OpportunitySetup.php

示例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);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:71,代码来源:OpportunityViews.php


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