Let the platform do the work

before_api_call

Overview

The before_api_call hook executes when the v10+ REST Service is about to call the API implementation.

Definition

  function before_api_call($event, $arguments){}

Arguments

Name Type Description
event String The name of the logic hook event
arguments Array Additional information related to the event
arguments.api Object The RestService Object
arguments.request Object The RestResponse Object

Considerations

  • This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php.
  • This hook can change the method being called and the parameters.
  • This hook should not be used for any type of display output.

Change Log

Version Note
7.0.0RC1 Added before_api_call hook

Example

./custom/modules/logic_hooks.php

  <?php

    $hook_version = 1;
    $hook_array = Array();

    $hook_array['before_api_call'] = Array();
    $hook_array['before_api_call'][] = Array(
        //Processing index. For sorting the array.
        1, 

        //Label. A string value to identify the hook.
        'before_api_call example', 

        //The PHP file where your class is located.
        'custom/modules/logic_hooks_class.php',

        //The class the method is in. 
        'logic_hooks_class',

        //The method to call. 
        'before_api_call_method' 
    );

?>

./custom/modules/logic_hooks_class.php

  <?php

    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class logic_hooks_class
    {
        function before_api_call_method($event, $arguments)
        {
            //logic
        }
    }

?>