當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LogicHook::call_custom_logic方法代碼示例

本文整理匯總了PHP中LogicHook::call_custom_logic方法的典型用法代碼示例。如果您正苦於以下問題:PHP LogicHook::call_custom_logic方法的具體用法?PHP LogicHook::call_custom_logic怎麽用?PHP LogicHook::call_custom_logic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LogicHook的用法示例。


在下文中一共展示了LogicHook::call_custom_logic方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: LogicHook

 /**
  * Trigger custom logic for this module that is defined for the provided hook
  * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
  * That file should define the $hook_version that should be used.
  * It should also define the $hook_array.  The $hook_array will be a two dimensional array
  * the first dimension is the name of the event, the second dimension is the information needed
  * to fire the hook.  Each entry in the top level array should be defined on a single line to make it
  * easier to automatically replace this file.  There should be no contents of this file that are not replacable.
  *
  * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1');
  * This sample line creates a before_save hook.  The hooks are procesed in the order in which they
  * are added to the array.  The second dimension is an array of:
  *		processing index (for sorting before exporting the array)
  *		A logic type hook
  *		label/type
  *		php file to include
  *		php class the method is in
  *		php method to call
  *
  * The method signature for version 1 hooks is:
  * function NAME(&$bean, $event, $arguments)
  * 		$bean - $this bean passed in by reference.
  *		$event - The string for the current event (i.e. before_save)
  * 		$arguments - An array of arguments that are specific to the event.
  */
 function call_custom_logic($event, $arguments = null)
 {
     if (!isset($this->processed) || $this->processed == false) {
         //add some logic to ensure we do not get into an infinite loop
         if (!empty($this->logicHookDepth[$event])) {
             if ($this->logicHookDepth[$event] > 10) {
                 return;
             }
         } else {
             $this->logicHookDepth[$event] = 0;
         }
         //we have to put the increment operator here
         //otherwise we may never increase the depth for that event in the case
         //where one event will trigger another as in the case of before_save and after_save
         //Also keeping the depth per event allow any number of hooks to be called on the bean
         //and we only will return if one event gets caught in a loop. We do not increment globally
         //for each event called.
         $this->logicHookDepth[$event]++;
         //method defined in 'include/utils/LogicHook.php'
         $logicHook = new LogicHook();
         $logicHook->setBean($this);
         $logicHook->call_custom_logic($this->module_dir, $event, $arguments);
     }
 }
開發者ID:rgauss,項目名稱:sugarcrm_dev,代碼行數:49,代碼來源:SugarBean.php

示例2: handleException

 /**
  * Handle exception
  * @param Exception $e
  */
 protected function handleException(Exception $e)
 {
     $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage());
     $logicHook = new LogicHook();
     if (isset($this->bean)) {
         $logicHook->setBean($this->bean);
         $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
     } else {
         $logicHook->call_custom_logic('', "handle_exception", $e);
     }
 }
開發者ID:sunmo,項目名稱:snowlotus,代碼行數:15,代碼來源:SugarController.php

示例3: testcall_custom_logic

 public function testcall_custom_logic()
 {
     //execute the method and test if it doesn't throws an exception
     $LogicHook = new LogicHook();
     $LogicHook->setBean(new Account());
     try {
         $LogicHook->call_custom_logic('', 'after_ui_footer');
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->fail();
     }
 }
開發者ID:sacredwebsite,項目名稱:SuiteCRM,代碼行數:12,代碼來源:LogicHookTest.php

示例4: array

 /**
  * Trigger custom logic for this module that is defined for the provided hook
  * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
  * That file should define the $hook_version that should be used.
  * It should also define the $hook_array.  The $hook_array will be a two dimensional array
  * the first dimension is the name of the event, the second dimension is the information needed
  * to fire the hook.  Each entry in the top level array should be defined on a single line to make it
  * easier to automatically replace this file.  There should be no contents of this file that are not replacable.
  *
  * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1');
  * This sample line creates a before_save hook.  The hooks are procesed in the order in which they
  * are added to the array.  The second dimension is an array of:
  *		processing index (for sorting before exporting the array)
  *		A logic type hook
  *		label/type
  *		php file to include
  *		php class the method is in
  *		php method to call
  *
  * The method signature for version 1 hooks is:
  * function NAME(&$bean, $event, $arguments)
  * 		$bean - $this bean passed in by reference.
  *		$event - The string for the current event (i.e. before_save)
  * 		$arguments - An array of arguments that are specific to the event.
  */
 function call_custom_logic($event, $arguments = array())
 {
     if (!isset($this->processed) || $this->processed == false) {
         //add some logic to ensure we do not get into an infinite loop
         if (!empty($this->logicHookDepth[$event])) {
             if ($this->logicHookDepth[$event] > $this->max_logic_depth) {
                 return;
             }
         } else {
             $this->logicHookDepth[$event] = 0;
         }
         //we have to put the increment operator here
         //otherwise we may never increase the depth for that event in the case
         //where one event will trigger another as in the case of before_save and after_save
         //Also keeping the depth per event allow any number of hooks to be called on the bean
         //and we only will return if one event gets caught in a loop. We do not increment globally
         //for each event called.
         $this->logicHookDepth[$event]++;
         //method defined in 'include/utils/LogicHook.php'
         $logicHook = new LogicHook();
         $logicHook->setBean($this);
         $logicHook->call_custom_logic($this->module_dir, $event, $arguments);
         $this->logicHookDepth[$event]--;
         //Fire dependency manager dependencies here for some custom logic types.
         if (in_array($event, array('after_relationship_add', 'after_relationship_delete', 'before_delete'))) {
             $this->updateRelatedCalcFields(isset($arguments['link']) ? $arguments['link'] : "");
         }
     }
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:54,代碼來源:SugarBean.php

示例5: handleException

 /**
  * Handle exception
  * @param Exception $e
  */
 protected function handleException(Exception $e)
 {
     $GLOBALS['log']->fatal('Exception in Controller: ' . $e);
     $logicHook = new LogicHook();
     SugarMetric_Manager::getInstance()->handleException($e);
     if (isset($this->bean)) {
         $logicHook->setBean($this->bean);
         $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
     } else {
         $logicHook->call_custom_logic('', "handle_exception", $e);
     }
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:16,代碼來源:SugarController.php


注:本文中的LogicHook::call_custom_logic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。