Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
schedulerevent.php
1<?php
2
3namespace Bitrix\Bizproc;
4
5use Bitrix\Main;;
6
23class SchedulerEventTable extends Main\Entity\DataManager
24{
28 public static function getTableName()
29 {
30 return 'b_bp_scheduler_event';
31 }
32
36 public static function getMap()
37 {
38 return array(
39 'ID' => array(
40 'data_type' => 'integer',
41 'primary' => true,
42 'autocomplete' => true,
43 ),
44 'WORKFLOW_ID' => array(
45 'data_type' => 'string'
46 ),
47 'HANDLER' => array(
48 'data_type' => 'string'
49 ),
50 'EVENT_MODULE' => array(
51 'data_type' => 'string'
52 ),
53 'EVENT_TYPE' => array(
54 'data_type' => 'string'
55 ),
56 'ENTITY_ID' => array(
57 'data_type' => 'string'
58 ),
59 'EVENT_PARAMETERS' => array(
60 'data_type' => 'text',
61 'serialized' => true
62 )
63 );
64 }
65
66 public static function deleteBySubscription($workflowId, $handler, $eventModule, $eventType, $entityId = null)
67 {
68 $connection = Main\Application::getConnection();
69 $sqlHelper = $connection->getSqlHelper();
70
71 $table = $sqlHelper->forSql(static::getTableName());
72 $workflowId = $sqlHelper->forSql($workflowId);
73 $handler = $sqlHelper->forSql($handler);
74 $eventModule = $sqlHelper->forSql($eventModule);
75 $eventType = $sqlHelper->forSql($eventType);
76 $entityId = $entityId !== null ? $sqlHelper->forSql($entityId) : null;
77
78 $connection->queryExecute("DELETE
79 FROM {$table}
80 WHERE
81 WORKFLOW_ID = '{$workflowId}'
82 AND HANDLER = '{$handler}'
83 AND EVENT_MODULE = '{$eventModule}'
84 AND EVENT_TYPE = '{$eventType}'"
85 .($entityId !== null ? " AND ENTITY_ID = '{$entityId}'" : '')
86 );
87 }
88
89 public static function deleteByWorkflow($workflowId)
90 {
91 $connection = Main\Application::getConnection();
92 $sqlHelper = $connection->getSqlHelper();
93
94 $table = $sqlHelper->forSql(static::getTableName());
95 $workflowId = $sqlHelper->forSql($workflowId);
96
97 $connection->queryExecute("DELETE FROM {$table} WHERE WORKFLOW_ID = '{$workflowId}'");
98 }
99
100 public static function isSubscribed($workflowId, $handler, $eventModule, $eventType, $entityId = null)
101 {
102 $filter = array(
103 '=WORKFLOW_ID' => (string)$workflowId,
104 '=HANDLER' => (string)$handler,
105 '=EVENT_MODULE' => (string)$eventModule,
106 '=EVENT_TYPE' => (string)$eventType
107 );
108
109 if ($entityId !== null)
110 $filter['=ENTITY_ID'] = (string)$entityId;
111
112 $row = static::getList(array(
113 'select' => array('ID'),
114 'filter' => $filter
115 ))->fetch();
116
117 return (is_array($row));
118 }
119
120 public static function hasSubscriptions($eventModule, $eventType)
121 {
122 $filter = array(
123 '=EVENT_MODULE' => $eventModule,
124 '=EVENT_TYPE' => $eventType
125 );
126
127 $row = static::getList(array(
128 'select' => array('ID'),
129 'filter' => $filter,
130 'limit' => 1
131 ))->fetch();
132
133 return (is_array($row));
134 }
135}
static deleteBySubscription($workflowId, $handler, $eventModule, $eventType, $entityId=null)
static hasSubscriptions($eventModule, $eventType)
static isSubscribed($workflowId, $handler, $eventModule, $eventType, $entityId=null)