Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
TrackingService.php
1<?php
2
4
6use Bitrix\Bizproc\Debugger\Mixins\WriterDebugTrack;
9
10class TrackingService extends \CBPTrackingService
11{
12 use WriterDebugTrack;
13
14 public function canWrite($type, $workflowId)
15 {
16 $session = Manager::getActiveSession();
17 if (!$session)
18 {
19 return false;
20 }
21
22 return $session->hasWorkflow($workflowId);
23 }
24
25 public function write(
26 $workflowId,
27 $type,
28 $actionName,
29 $executionStatus,
30 $executionResult,
31 $actionTitle = "",
32 $actionNote = "",
33 $modifiedBy = 0
34 ): ?int
35 {
36 if (in_array((int)$type, self::DEBUG_TRACK_TYPES, true))
37 {
38 if (!is_array($actionNote))
39 {
40 $actionNote = $this->preparePropertyForWritingToTrack($actionNote);
41 }
42
43 $actionNote = \Bitrix\Main\Web\Json::encode($actionNote);
44 }
45
46 $id = parent::write(
47 $workflowId,
48 $type,
49 $actionName,
50 $executionStatus,
51 $executionStatus,
52 $actionTitle,
53 $actionNote,
54 $modifiedBy
55 );
56
57 $trackingResult = new \CBPTrackingServiceResult();
58 $trackingResult->InitFromArray([
59 $id => [
60 'ID' => $id,
61 'WORKFLOW_ID' => $workflowId,
62 'TYPE' => $type,
63 'ACTION_NAME' => $actionName,
64 'ACTION_TITLE' => $actionTitle,
65 'ACTION_NOTE' => $actionNote,
66 'MODIFIED' => (string)(new DateTime()),
67 ]
68 ]);
69
70 $result = $trackingResult->fetch();
71 Listener::getInstance()->onTrackWrite($result);
72
73 return $id;
74 }
75}
write( $workflowId, $type, $actionName, $executionStatus, $executionResult, $actionTitle="", $actionNote="", $modifiedBy=0)