Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
binding.php
1<?php
3
4use \Bitrix\Landing\Block\Cache;
5
7{
11 const BINDING_TYPE_BLOCK = 'B';
12
17 public static $internalClass = 'ChatBindingTable';
18
24 public static function clearCache(int $chatId): void
25 {
26 $res = self::getList([
27 'select' => [
28 'ENTITY_ID'
29 ],
30 'filter' => [
31 'INTERNAL_CHAT_ID' => $chatId,
32 '=ENTITY_TYPE' => self::BINDING_TYPE_BLOCK
33 ]
34 ]);
35 while ($row = $res->fetch())
36 {
37 Cache::clear($row['ENTITY_ID']);
38 }
39 }
40
47 public static function bindingBlock(int $chatId, int $blockId): void
48 {
49 $res = self::getList([
50 'select' => [
51 'ID'
52 ],
53 'filter' => [
54 'INTERNAL_CHAT_ID' => $chatId,
55 'ENTITY_ID' => $blockId,
56 '=ENTITY_TYPE' => self::BINDING_TYPE_BLOCK
57 ]
58 ]);
59 if (!$res->fetch())
60 {
61 self::add([
62 'INTERNAL_CHAT_ID' => $chatId,
63 'ENTITY_ID' => $blockId,
64 'ENTITY_TYPE' => self::BINDING_TYPE_BLOCK
65 ]);
66 }
67 }
68
74 public static function unbindingBlock(int $blockId): void
75 {
76 $res = self::getList([
77 'select' => [
78 'ID'
79 ],
80 'filter' => [
81 'ENTITY_ID' => $blockId,
82 '=ENTITY_TYPE' => self::BINDING_TYPE_BLOCK
83 ]
84 ]);
85 while ($row = $res->fetch())
86 {
87 self::delete($row['ID']);
88 }
89 }
90}
static bindingBlock(int $chatId, int $blockId)
Definition binding.php:47
static clearCache(int $chatId)
Definition binding.php:24
static unbindingBlock(int $blockId)
Definition binding.php:74