Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userconsentitem.php
1<?php
9
14
15Loc::loadMessages(__FILE__);
16
33class UserConsentItemTable extends Entity\DataManager
34{
40 public static function getTableName()
41 {
42 return 'b_consent_user_consent_item';
43 }
44
53 public static function getMap()
54 {
55 return [
56 'ID' => [
57 'data_type' => 'integer',
58 'primary' => true,
59 'autocomplete' => true,
60 ],
61 'USER_CONSENT_ID' => [
62 'data_type' => 'integer',
63 'required' => true,
64 ],
65 'VALUE' => [
66 'data_type' => 'text',
67 'required' => true,
68 ],
69 (new Reference(
70 'USER_CONSENT',
71 ConsentTable::class,
72 Join::on('this.USER_CONSENT_ID', 'ref.ID')
73 ))
74 ];
75 }
76
84 public static function addItems(int $userConsentId, array $items): void
85 {
86 foreach ($items as $item)
87 {
88 static::add([
89 'USER_CONSENT_ID' => $userConsentId,
90 'VALUE' => $item['VALUE'],
91 ]);
92 }
93 }
94
105 public static function getItems(int $userConsentId): array
106 {
107 $items = [];
108
109 $queryObject = static::getList([
110 'filter' => [
111 '=USER_CONSENT_ID' => $userConsentId
112 ]
113 ]);
114 while ($item = $queryObject->fetch())
115 {
116 $items[] = $item;
117 }
118
119 return $items;
120 }
121
130 public static function removeItems(int $userConsentId): void
131 {
132 $queryObject = static::getList([
133 'select' => ['ID'],
134 'filter' => [
135 '=USER_CONSENT_ID' => $userConsentId
136 ]
137 ]);
138 while ($item = $queryObject->fetch())
139 {
140 static::delete($item['ID']);
141 }
142 }
143}
static loadMessages($file)
Definition loc.php:64