Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit c2841a4

Browse files
authored
Merge pull request #218 from mesilov/issue#217
add onApiCallMethod
2 parents 1ca35d4 + dfad157 commit c2841a4

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/bitrix24.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)