Skip to content

Instantly share code, notes, and snippets.

@SugarCRMExamples
Created March 18, 2014 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SugarCRMExamples/9623040 to your computer and use it in GitHub Desktop.
Save SugarCRMExamples/9623040 to your computer and use it in GitHub Desktop.
<?php
require_once('modules/Contacts/ContactsApiHelper.php');
// Since the ContactsApiHelper exists, we'll extend it
// If it didn't we would just extend the SugarBeanApiHelper
class CustomContactsApiHelper extends ContactsApiHelper
{
// Mimic the SugarBeanApiHelper->formatForApi() class
public function formatForApi(SugarBean $bean, array $fieldList = array(), array $options = array())
{
// First off, call the parent class
$data = parent::formatForApi($bean, $fieldList, $options);
// Make sure they requested the top_opp field, or no field restriction at all
if (empty($fieldList) || in_array('top_opp', $fieldList) ) {
// Let's just put some filler data in here for now
$data['top_opp'] = 'Rest in Peas Burger';
}
// formatForApi returns the bean formatted as a hash in API format
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment