Last active
August 29, 2015 14:22
-
-
Save mmarum-sugarcrm/84a0d0883c2423ae4c38 to your computer and use it in GitHub Desktop.
Sugar 7 Mobile API Logic Hook example
This file contains hidden or 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 | |
$hook_version = 1; | |
$hook_array = Array(); | |
$hook_array['after_routing'] = Array(); | |
$hook_array['after_routing'][] = Array( | |
//Processing index. For sorting the array. | |
1, | |
//Label. A string value to identify the hook. | |
'after_routing mobile logic hook', | |
//The PHP file where your class is located. | |
'custom/MobileApiLogicHook.php', | |
//The class the method is in. | |
'MobileApiLogicHook', | |
//The method to call. | |
'logMobileAfterRouting' | |
); |
This file contains hidden or 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 | |
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
/** | |
* Example Mobile API Logic Hooks class | |
**/ | |
class MobileApiLogicHook | |
{ | |
/** | |
* Logic hook function tied to 'after_routing' event | |
*/ | |
function logMobileAfterRouting($event, $arguments) | |
{ | |
//Sugar Logger | |
global $log; | |
//If request came from a Mobile platform | |
if($arguments['api']->platform == "mobile"){ | |
$path = $arguments['api']->getRequest()->getPath(); | |
//Write request path to sugarcrm.log file | |
$log->fatal("Mobile request to " . json_encode($path)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment