Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function apiFormatField(array &$data, SugarBean $bean, array $args, $fieldName, $properties, array $fieldList = null, ServiceBase $service = null)
 {
     $this->ensureApiFormatFieldArguments($fieldList, $service);
     // this is only for generated links
     if (isset($bean->field_defs[$fieldName]['gen']) && isTruthy($bean->field_defs[$fieldName]['gen'])) {
         $subject = $bean->field_defs[$fieldName]['default'];
         if (!empty($subject)) {
             $data[$fieldName] = replace_sugar_vars($subject, $bean->toArray(), true);
         } else {
             $data[$fieldName] = "";
         }
     } else {
         parent::apiFormatField($data, $bean, $args, $fieldName, $properties, $fieldList, $service);
     }
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function apiFormatField(array &$data, SugarBean $bean, array $args, $fieldName, $properties, array $fieldList = null, ServiceBase $service = null)
 {
     // Handle the parent so our current data element is set
     parent::apiFormatField($data, $bean, $args, $fieldName, $properties, $fieldList, $service);
     // Get fields related to this field but only if the current field is empty
     // If the current field is empty, set it to the related field(s) until it
     // isn't empty. This happens in the case of upload file fields in File
     // type SugarObject based custom modules. In most cases the fields array
     // will either be empty or one entry long.
     if (empty($data[$fieldName]) && isset($properties['fields'])) {
         foreach ($properties['fields'] as $field) {
             if (empty($data[$field])) {
                 $data[$field] = empty($bean->{$field}) ? '' : $bean->{$field};
             }
             $data[$fieldName] = $data[$field];
             break;
         }
     }
     // Add in file_mime_type
     if (empty($data['file_mime_type'])) {
         $data['file_mime_type'] = empty($bean->file_mime_type) ? '' : $bean->file_mime_type;
     }
 }