Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
feedgarbagecollector.php
1<?php
10
13
15{
16 public const LIMIT = 1000;
17
18 private static $processing = false;
19
20 public static function execute()
21 {
22 if (self::$processing)
23 {
24 return self::getAgentName();
25 }
26
27 self::$processing = true;
28
29 $agent = new self();
30 $res = $agent->run();
31
32 self::$processing = false;
33
34 return $res;
35 }
36
40 private static function getAgentName(): string
41 {
42 return self::class . "::execute();";
43 }
44
45 private function __construct()
46 {
47
48 }
49
54 private function run(): string
55 {
56 $types = $this->getTypes();
57 if (empty($types))
58 {
59 return '';
60 }
61
62 $logIds = $this->getLogIds($types);
63 if (empty($logIds))
64 {
65 return '';
66 }
67
68 foreach ($logIds as $logId)
69 {
70 \CSocNetLog::Delete($logId);
71 }
72
73 return self::getAgentName();
74 }
75
83 private function getLogIds(array $types): array
84 {
85 $logIds = LogTable::getList([
86 'select' => ['ID'],
87 'filter' => [
88 '@ENTITY_TYPE' => $types,
89 ],
90 'limit' => self::LIMIT,
91 'order' => ['ID' => 'ASC'],
92 ])->fetchAll();
93 if (empty($logIds))
94 {
95 return [];
96 }
97
98 return array_column($logIds, 'ID');
99 }
100
105 private function getTypes(): array
106 {
107 if (!Loader::includeModule('crm'))
108 {
109 return [];
110 }
111
112 return [
113 SONET_CRM_LEAD_ENTITY,
114 SONET_CRM_CONTACT_ENTITY,
115 SONET_CRM_COMPANY_ENTITY,
116 SONET_CRM_DEAL_ENTITY,
117 SONET_CRM_ACTIVITY_ENTITY,
118 SONET_CRM_INVOICE_ENTITY,
119 SONET_CRM_ORDER_ENTITY,
120 SONET_CRM_SUSPENDED_LEAD_ENTITY,
121 SONET_SUSPENDED_CRM_CONTACT_ENTITY,
122 SONET_SUSPENDED_CRM_COMPANY_ENTITY,
123 SONET_CRM_SUSPENDED_DEAL_ENTITY,
124 SONET_CRM_SUSPENDED_ACTIVITY_ENTITY,
125 ];
126 }
127}
static getList(array $parameters=array())