@@ -143,6 +143,11 @@ class Bitrix24 implements iBitrix24
143143 */
144144 protected $ _onExpiredToken ;
145145
146+ /**
147+ * @var callable callback after api method called
148+ */
149+ protected $ _onCallApiMethod ;
150+
146151 /**
147152 * @var bool ssl verify for checking CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST
148153 */
@@ -204,6 +209,16 @@ public function setOnExpiredToken(callable $callback)
204209 $ this ->_onExpiredToken = $ callback ;
205210 }
206211
212+ /**
213+ * Set function called after api method executed. Callback receives instance as first parameter, method name as second.
214+ *
215+ * @param callable $callback
216+ */
217+ public function setOnCallApiMethod (callable $ callback )
218+ {
219+ $ this ->_onCallApiMothod = $ callback ;
220+ }
221+
207222 /**
208223 * Get a random string to sign protected api-call. Use salt for argument "state" in secure api-call
209224 * random string is a result of mt_rand function
@@ -1114,8 +1129,13 @@ public function processBatchCalls($halt = 0, $delay = self::BATCH_DELAY)
11141129 public function call ($ methodName , array $ additionalParameters = array ())
11151130 {
11161131 try {
1117- $ result = $ this ->getWebhookUsage () ? $ this ->_call_webhook ($ methodName , $ additionalParameters )
1118- : $ this ->_call ($ methodName , $ additionalParameters );
1132+ $ result = $ this ->getWebhookUsage () ? $ this ->_call_webhook ($ methodName , $ additionalParameters )
1133+ : $ this ->_call ($ methodName , $ additionalParameters );
1134+
1135+ if (is_callable ($ this ->_onCallApiMothod )) {
1136+ call_user_func ($ this ->_onCallApiMothod , $ this , $ methodName );
1137+ }
1138+
11191139 } catch (Bitrix24TokenIsExpiredException $ e ) {
11201140 if (!is_callable ($ this ->_onExpiredToken )) {
11211141 throw $ e ;
0 commit comments