Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
column.php
1<?php
2
4
11
12class Column
13{
15
16 protected string $id;
17 protected string $type;
18 protected ?string $name;
19 protected ?string $sort;
20 protected bool $default = false;
29 protected bool $necessary = false;
37 protected array $select;
38 protected bool $multiple = false;
39 protected ?Config $editableConfig = null;
40
45 public function __construct(string $id, array $params = [])
46 {
47 $this->setId($id);
48
49 $this
50 ->setType(
51 empty($params['type']) ? Type::TEXT : $params['type']
52 )
53 ->setName($params['name'] ?? null)
54 ->setSort($params['sort'] ?? null)
55 ->setAlign($params['align'] ?? null)
56 ->setTitle($params['title'] ?? null)
57 ->setWidth($params['width'] ?? null)
58 ->setSection($params['section_id'] ?? null)
59 ->setCssClassName($params['class'] ?? null)
60 ;
61
62 $this->setSelect($params['select'] ?? [ $id ]);
63
64 if (isset($params['editable']))
65 {
66 $this->setEditable($params['editable']);
67 }
68
69 if (isset($params['first_order']))
70 {
71 $this->setFirstOrder($params['first_order']);
72 }
73
74 if (isset($params['default']))
75 {
76 $this->setDefault($params['default']);
77 }
78
79 if (isset($params['necessary']))
80 {
81 $this->setNecessary($params['necessary']);
82 }
83
84 if (isset($params['multiple']))
85 {
86 $this->setMultiple($params['multiple']);
87 }
88
89 if (isset($params['resizeable']))
90 {
91 $this->setResizeable($params['resizeable']);
92 }
93
94 if (isset($params['prevent_default']))
95 {
96 $this->setPreventDefault($params['prevent_default']);
97 }
98
99 if (isset($params['sticked']))
100 {
101 $this->setSticked($params['sticked']);
102 }
103
104 if (isset($params['shift']))
105 {
106 $this->setShift($params['shift']);
107 }
108
109 if (isset($params['showname']))
110 {
111 $this->setShowname($params['showname']);
112 }
113
114 $color = $params['color'] ?? null;
115 if (isset($color) && is_string($color))
116 {
117 if (self::isValidCssColorValue($color))
118 {
119 $this->setCssColorValue($color);
120 }
121 else
122 {
123 $this->setCssColorClassName($color);
124 }
125 }
126
127 if (isset($params['iconUrl']))
128 {
129 $this->setIcon(
130 new Icon(
131 $params['iconUrl'],
132 $params['iconTitle'] ?? null
133 )
134 );
135 }
136
137 if (isset($params['hint']))
138 {
139 $hint = new Hint($params['hint']);
140
141 if (isset($params['hintHtml']) && is_bool($params['hintHtml']))
142 {
143 $hint->setHtml($params['hintHtml']);
144 }
145
146 if (isset($params['hintInteractivity']) && is_bool($params['hintInteractivity']))
147 {
148 $hint->setInteractivity($params['hintInteractivity']);
149 }
150
151 $this->setHint($hint);
152 }
153 }
154
155 public function setId(string $id): self
156 {
157 $id = trim($id);
158 if (empty($id))
159 {
160 throw new ArgumentNullException('id');
161 }
162
163 $this->id = $id;
164
165 return $this;
166 }
167
168 public function getId(): string
169 {
170 return $this->id;
171 }
172
182 public function setType(string $type): self
183 {
184 $type = trim($type);
185 if (empty($type))
186 {
187 throw new ArgumentNullException('type');
188 }
189
190 $this->type = $type;
191
192 return $this;
193 }
194
195 public function getType(): string
196 {
197 return $this->type;
198 }
199
200 public function setName(?string $name): self
201 {
202 $this->name = $name;
203
204 return $this;
205 }
206
207 public function getName(): ?string
208 {
209 return $this->name;
210 }
211
212 public function setDefault(bool $default): self
213 {
214 $this->default = $default;
215
216 return $this;
217 }
218
219 public function isDefault(): bool
220 {
221 return $this->default;
222 }
223
224 public function setNecessary(bool $necessary): self
225 {
226 $this->necessary = $necessary;
227
228 return $this;
229 }
230
236 public function isNecessary(): bool
237 {
238 return $this->necessary;
239 }
240
246 public function setEditable($value): self
247 {
248 if (is_bool($value))
249 {
250 if ($value)
251 {
252 $this->editableConfig = (new ConfigFactory)->createFromColumn($this);
253 }
254 else
255 {
256 $this->editableConfig = null;
257 }
258 }
259 elseif ($value instanceof Config)
260 {
261 $this->editableConfig = $value;
262 }
263 else
264 {
265 throw new ArgumentTypeException('editable', '\Bitrix\Main\Grid\Column\Editable\Config|bool');
266 }
267
268 return $this;
269 }
270
271 public function getEditable(): ?Config
272 {
273 return $this->editableConfig;
274 }
275
276 public function isEditable(): bool
277 {
278 return isset($this->editableConfig);
279 }
280
281 public function setMultiple(bool $multiple): self
282 {
283 $this->multiple = $multiple;
284
285 return $this;
286 }
287
288 public function isMultiple(): bool
289 {
290 return $this->multiple;
291 }
292
293 public function setSort(?string $sort): self
294 {
295 $this->sort = $sort;
296
297 return $this;
298 }
299
300 public function getSort(): ?string
301 {
302 return $this->sort;
303 }
304
305 public function setSelect(array $select): self
306 {
307 $this->select = $select;
308
309 return $this;
310 }
311
312 public function getSelect(): array
313 {
314 return $this->select;
315 }
316}
setNecessary(bool $necessary)
Definition column.php:224
setMultiple(bool $multiple)
Definition column.php:281
__construct(string $id, array $params=[])
Definition column.php:45
setInteractivity(bool $value)
Definition hint.php:85