Created
March 18, 2014 15:59
-
-
Save SugarCRMExamples/9623040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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