Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
placementlang.php
1<?php
2
3namespace Bitrix\Rest;
4
12
43{
49 public static function getTableName()
50 {
51 return 'b_rest_placement_lang';
52 }
53
59 public static function getMap()
60 {
61 return [
62 new IntegerField(
63 'ID',
64 [
65 'primary' => true,
66 'autocomplete' => true,
67 ]
68 ),
69 new IntegerField(
70 'PLACEMENT_ID',
71 [
72 'required' => true,
73 ]
74 ),
75 new StringField(
76 'LANGUAGE_ID',
77 [
78 'required' => true,
79 'validation' => [__CLASS__, 'validateLanguageId'],
80 ]
81 ),
82 new StringField(
83 'TITLE',
84 [
85 'required' => true,
86 'validation' => [__CLASS__, 'validateTitle'],
87 ]
88 ),
89 new StringField(
90 'DESCRIPTION',
91 [
92 'validation' => [__CLASS__, 'validateDescription'],
93 ]
94 ),
95 new StringField(
96 'GROUP_NAME',
97 [
98 'validation' => [__CLASS__, 'validateGroupName'],
99 ]
100 ),
101 new Reference(
102 'PLACEMENT',
103 \Bitrix\Rest\PlacementLangTable::class,
104 Join::on('this.PLACEMENT_ID', 'ref.ID')
105 ),
106 ];
107 }
108
114 public static function validateLanguageId()
115 {
116 return [
117 new LengthValidator(null, 2),
118 ];
119 }
120
126 public static function validateTitle()
127 {
128 return [
129 new LengthValidator(null, 255),
130 ];
131 }
132
138 public static function validateDescription()
139 {
140 return [
141 new LengthValidator(null, 255),
142 ];
143 }
144
150 public static function validateGroupName()
151 {
152 return [
153 new LengthValidator(null, 255),
154 ];
155 }
156
157 private static function getPlacementTableName()
158 {
160 }
161
162
170 public static function deleteByApp(int $appId) : Main\DB\Result
171 {
172 $connection = Main\Application::getConnection();
173
174 $placementLangTableName = static::getTableName();
175 $placementTableName = static::getPlacementTableName();
176
177 return $connection->query(
178 'DELETE ' . $placementLangTableName . ' FROM ' . $placementLangTableName . '
179 INNER JOIN ' . $placementTableName . ' ON (' . $placementTableName . '.ID = ' . $placementLangTableName . '.PLACEMENT_ID)
180 WHERE b_rest_placement.APP_ID = \'' . $appId . '\''
181 );
182 }
183
191 public static function deleteByPlacement(int $placementId) : Main\DB\Result
192 {
193 $connection = Main\Application::getConnection();
194
195 return $connection->query('DELETE FROM ' . static::getTableName() . ' WHERE PLACEMENT_ID=\'' . $placementId . '\'');
196 }
197}
static deleteByPlacement(int $placementId)