sugar crm逻辑钩子没有调用函数

时间:2017-12-14 06:13:55

标签: function sugarcrm

documentHook.php文件

class DocumentsHooks
{
     public function before_save_actions($bean) 
    {
        smartLogger(__LINE__." : " . __CLASS__ . " : " . $bean->template_type. " ID : " . $bean->so_purchases_documents_1so_purchases_ida);

        if($bean->template_type == 'poa' && $bean->so_purchases_documents_1so_purchases_ida != '') {
            smartLogger(__LINE__." : " . __CLASS__ . " : " . $bean->template_type);
            $purchaseBean = PurchaseUtil::getPurchaseBean($bean->so_purchases_documents_1so_purchases_ida);
            $purchaseBean->signtype = 'POA';
            $purchaseBean->save();
            smartLogger(__LINE__." : " . __CLASS__ . " : Saved " );
        }
    } 
}

logic_hooks.php

<?php
    $hook_version = 1;
    $hook_array = Array();

    $hook_array['before_save']      = Array();
    $hook_array['before_save'][]    = Array(1, 'DocumentsHooks', 'custom/modules/Documents/DocumentsHooks.php','DocumentsHooks', 'before_save_actions');
?>

我试过调用这个函数,但是类正在创建而不是调用函数。任何人吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

./custom/Extension/modules/Accounts/Ext/LogicHooks/<file>.php

<?php

    $hook_array['before_save'][] = array(
        1,
        'Hook description',
        'custom/modules/Accounts/customLogicHook.php',
        'className',
        'methodName'
    );
?>

./custom/modules/Accounts/customLogicHook.php

<?php

    class className
    {
        function methodName($bean, $event, $arguments)
        {
            //logic
        }
    }
?>

This link will help you