1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
scalarfield.php
См. документацию.
1<?php
8
9namespace Bitrix\Main\ORM\Fields;
10
11use Bitrix\Main\DB\SqlExpression;
12
18abstract class ScalarField extends Field implements IStorable, ITypeHintable
19{
20 protected $is_primary;
21
22 protected $is_unique;
23
24 protected $is_required;
25
27
29 protected $is_private;
30
32 protected $is_nullable;
33
35 protected $is_binary = false;
36
38 protected $is_fulltext = false;
39
40 protected $column_name = '';
41
43 protected $default_value;
44
53 public function __construct($name, $parameters = array())
54 {
55 parent::__construct($name, $parameters);
56
57 $this->is_primary = (isset($parameters['primary']) && $parameters['primary']);
58 $this->is_unique = (isset($parameters['unique']) && $parameters['unique']);
59 $this->is_required = (isset($parameters['required']) && $parameters['required']);
60 $this->is_autocomplete = (isset($parameters['autocomplete']) && $parameters['autocomplete']);
61 $this->is_private = (isset($parameters['private']) && $parameters['private']);
62 $this->is_nullable = (isset($parameters['nullable']) && $parameters['nullable']);
63 $this->is_binary = (isset($parameters['binary']) && $parameters['binary']);
64 $this->is_fulltext = (isset($parameters['fulltext']) && $parameters['fulltext']);
65
66 $this->column_name = $parameters['column_name'] ?? $this->name;
67 $this->default_value = $parameters['default_value'] ?? null;
68 }
69
73 public function getTypeMask()
74 {
76 }
77
83 public function configurePrimary($value = true)
84 {
85 $this->is_primary = (bool) $value;
86 return $this;
87 }
88
89 public function isPrimary()
90 {
91 return $this->is_primary;
92 }
93
99 public function configureRequired($value = true)
100 {
101 $this->is_required = (bool) $value;
102 return $this;
103 }
104
105 public function isRequired()
106 {
107 return $this->is_required;
108 }
109
115 public function configureUnique($value = true)
116 {
117 $this->is_unique = (bool) $value;
118 return $this;
119 }
120
121 public function isUnique()
122 {
123 return $this->is_unique;
124 }
125
131 public function configureAutocomplete($value = true)
132 {
133 $this->is_autocomplete = (bool) $value;
134 return $this;
135 }
136
137 public function isAutocomplete()
138 {
140 }
141
142
148 public function configurePrivate($value = true)
149 {
150 $this->is_private = (bool) $value;
151 return $this;
152 }
153
157 public function isPrivate()
158 {
159 return $this->is_private;
160 }
161
167 public function configureNullable($value = true)
168 {
169 $this->is_nullable = (bool) $value;
170 return $this;
171 }
172
176 public function isNullable()
177 {
178 return $this->is_nullable;
179 }
180
186 public function configureBinary($value = true)
187 {
188 $this->is_binary = (bool) $value;
189 return $this;
190 }
191
195 public function isBinary()
196 {
197 return $this->is_binary;
198 }
199
205 public function configureFulltext($value = true)
206 {
207 $this->is_fulltext = (bool) $value;
208 return $this;
209 }
210
214 public function isFulltext()
215 {
216 return $this->is_fulltext;
217 }
218
224 public function configureColumnName($value)
225 {
226 $this->column_name = $value;
227 return $this;
228 }
229
230 public function getColumnName()
231 {
232 return $this->column_name;
233 }
234
239 {
240 $this->column_name = $column_name;
241 }
242
248 public function configureDefaultValue($value)
249 {
250 $this->default_value = $value;
251 return $this;
252 }
253
259 public function getDefaultValue($row = null)
260 {
261 if (!is_string($this->default_value) && is_callable($this->default_value))
262 {
263 return call_user_func($this->default_value, $row);
264 }
265 else
266 {
268 }
269 }
270
271 public function isValueEmpty($value)
272 {
273 if ($value instanceof SqlExpression)
274 {
275 $value = $value->compile();
276 }
277
278 return ((string)$value === '');
279 }
280
284 public function getGetterTypeHint()
285 {
286 return $this->getNullableTypeHint('\\string');
287 }
288
292 public function getSetterTypeHint()
293 {
294 return $this->getNullableTypeHint('\\string');
295 }
296
301 protected function getNullableTypeHint(string $type): string
302 {
303 return $this->is_nullable ? 'null|' . $type : $type;
304 }
305}
$type
Определения options.php:106
configureDefaultValue($value)
Определения scalarfield.php:248
configureColumnName($value)
Определения scalarfield.php:224
configurePrivate($value=true)
Определения scalarfield.php:148
configurePrimary($value=true)
Определения scalarfield.php:83
configureAutocomplete($value=true)
Определения scalarfield.php:131
getDefaultValue($row=null)
Определения scalarfield.php:259
setColumnName($column_name)
Определения scalarfield.php:238
configureNullable($value=true)
Определения scalarfield.php:167
configureRequired($value=true)
Определения scalarfield.php:99
configureUnique($value=true)
Определения scalarfield.php:115
configureBinary($value=true)
Определения scalarfield.php:186
__construct($name, $parameters=array())
Определения scalarfield.php:53
configureFulltext($value=true)
Определения scalarfield.php:205
getNullableTypeHint(string $type)
Определения scalarfield.php:301
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804