Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
callbackregistry.php
1<?php
2
4
7
13{
19 public static function add(array $data)
20 {
21 $dbRes = Sale\Internals\CallbackRegistryTable::add([
22 'DATE_INSERT' => new Main\Type\DateTime(),
23 'DOCUMENT_ID' => $data['DOCUMENT_ID'],
24 'MODULE_ID' => $data['MODULE_ID'],
25 'CALLBACK_CLASS' => $data['CALLBACK_CLASS'],
26 'CALLBACK_METHOD' => $data['CALLBACK_METHOD'],
27 ]);
28
29 return $dbRes->isSuccess();
30 }
31
39 public static function onDocumentGenerated(Main\Event $event)
40 {
41 $documentId = $event->getParameter('documentId');
42 $data = $event->getParameter('data');
43
44 $dbRes = Sale\Internals\CallbackRegistryTable::getList([
45 'filter' => [
46 '=DOCUMENT_ID' => $documentId
47 ]
48 ]);
49
50 if ($result = $dbRes->fetch())
51 {
52 if (!Main\ModuleManager::isModuleInstalled($result['MODULE_ID']))
53 {
54 return;
55 }
56
57 Main\Loader::includeModule($result['MODULE_ID']);
58
59 $class = $result['CALLBACK_CLASS'];
60 $method = $result['CALLBACK_METHOD'];
61
62 $class::$method($data['value']);
63
64 Sale\Internals\CallbackRegistryTable::delete($result['ID']);
65 }
66 }
67}