Working With SugarCRM Logic Hooks

There are two ways of installing logic hooks: one works fine, the other seems to cause problems.

The way not to use is a log_hooks array within the manifest file as follows.

'logic_hooks' => array(
array(
'module' => 'Emails',
'hook' => 'after_save',
'order' => 200,
'description' => 'This logic hook looks at a saved email and adds a       history record.',
'file' => 'custom/include/classes/History.class.php',
'class' => 'History',
'function' => 'addHistory',
),

You are much better to user the copy process as follows. Follow exactly the directory names.
Also, make the actual file name something unique, so that it doesn’t match an existing file for other logic hooks.

'copy' => array (
0 => array (
'from' => '/Files/custom/Extension/modules/Emails/Ext/LogicHooks/history_logic_hooks.php',
'to' => 'custom/Extension/modules/Emails/Ext/LogicHooks/history_logic_hooks.php',
),

Where the file referred to (eg.history_logic_hooks.php) holds the definition like this.

// logic hook to handle history // 3-oct-2017
$hook_array['after_save'][]
= Array( 200, 'Save History', 'custom/include/classes/history.class.php', 'History', 'addHistory' );

Of course you also have to copy the class file you refer to.