Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
field.php
1
<?php
2
namespace
Bitrix\Main\Filter
;
3
4
class
Field
5
{
7
protected
$dataProvider
=
null
;
9
protected
$id
=
''
;
11
protected
$name
=
''
;
13
protected
$type
=
''
;
15
protected
$isDefault
=
false
;
17
protected
$data
=
null
;
19
protected
$isPartial
=
false
;
21
protected
$sectionId
=
''
;
22
protected
$iconParams
= [];
23
24
public
function
__construct
(
DataProvider
$dataProvider
,
$id
, array $params =
null
)
25
{
26
$this->dataProvider =
$dataProvider
;
27
$this->
id
=
$id
;
28
29
if
(!is_array($params))
30
{
31
$params = [];
32
}
33
34
$this->name = $params[
'name'
] ??
$id
;
35
$this->type = $params[
'type'
] ??
''
;
36
$this->
isDefault
= $params[
'default'
] ??
false
;
37
38
$this->
isPartial
= $params[
'partial'
] ??
false
;
39
$this->data = $params[
'data'
] ??
null
;
40
}
41
46
public
function
getDataProvider
()
47
{
48
return
$this->dataProvider
;
49
}
50
55
public
function
setDataProvider
(
DataProvider
$dataProvider
)
56
{
57
$this->dataProvider =
$dataProvider
;
58
}
63
protected
function
prepareData
()
64
{
65
return
$this->dataProvider->prepareFieldData($this->
id
);
66
}
71
public
function
prepareHtml
()
72
{
73
return
$this->dataProvider->prepareFieldHtml($this);
74
}
79
public
function
getId
()
80
{
81
return
$this->id
;
82
}
87
public
function
setID
(
$id
)
88
{
89
$this->
id
=
$id
;
90
}
95
public
function
getName
()
96
{
97
return
$this->name
;
98
}
103
public
function
setName
(
$name
)
104
{
105
$this->name =
$name
;
106
}
111
public
function
getType
()
112
{
113
return
$this->type
;
114
}
119
public
function
setType
(
$type
)
120
{
121
$this->type =
$type
;
122
}
127
public
function
isDefault
()
128
{
129
return
$this->isDefault
;
130
}
135
public
function
markAsDefault
(
$isDefault
)
136
{
137
$this->
isDefault
=
$isDefault
;
138
}
145
public
function
isPartial
()
146
{
147
return
$this->isPartial
;
148
}
153
public
function
getData
()
154
{
155
return
$this->data
;
156
}
162
public
function
getDataItem
($key)
163
{
164
return
$this->data !==
null
&& isset($this->data[$key]) ? $this->data[$key] :
null
;
165
}
166
171
public
function
getSectionId
(): string
172
{
173
return
$this->sectionId
;
174
}
175
180
public
function
setSectionId
(
string
$sectionId
): void
181
{
182
$this->sectionId =
$sectionId
;
183
}
188
public
function
getIconParams
(): array
189
{
190
return
$this->iconParams
;
191
}
192
197
public
function
setIconParams
(array
$iconParams
): void
198
{
199
$this->iconParams =
$iconParams
;
200
}
201
207
public
function
assemble
()
208
{
209
if
(!$this->
isPartial
)
210
{
211
return
;
212
}
213
214
$this->data = $this->
prepareData
();
215
$this->
isPartial
=
false
;
216
217
if
(is_array($this->data))
218
{
219
$html = $this->
prepareHtml
();
220
if
($html !==
''
)
221
{
222
$this->data[
'html'
] = $html;
223
}
224
}
225
}
231
public
function
toArray
(array $options =
null
)
232
{
233
if
(!is_array($options))
234
{
235
$options = [];
236
}
237
238
$result = [
'id'
=>
$this->id
,
'name'
=>
$this->name
];
239
if
($this->type !==
''
)
240
{
241
$result[
'type'
] =
$this->type
;
242
}
243
244
if
($this->
isDefault
)
245
{
246
$result[
'default'
] =
true
;
247
}
248
249
if
($this->sectionId !==
''
)
250
{
251
$result[
'sectionId'
] =
$this->sectionId
;
252
}
253
if
(!empty($this->iconParams))
254
{
255
$result[
'icon'
] =
$this->iconParams
;
256
}
257
258
if
(isset($options[
'lightweight'
]) && $options[
'lightweight'
])
259
{
260
$result[
'lightweight'
] =
true
;
261
return
$result;
262
}
263
264
if
($this->
isPartial
())
265
{
266
$this->
assemble
();
267
}
268
269
if
(is_array($this->data))
270
{
271
foreach
($this->data as $key =>
$data
)
272
{
273
$result[$key] =
$data
;
274
}
275
}
276
277
return
$result;
278
}
279
}
Bitrix\Main\Filter\DataProvider
Definition
dataprovider.php:5
Bitrix\Main\Filter\Field
Definition
field.php:5
Bitrix\Main\Filter\Field\isDefault
isDefault()
Definition
field.php:127
Bitrix\Main\Filter\Field\getId
getId()
Definition
field.php:79
Bitrix\Main\Filter\Field\setName
setName($name)
Definition
field.php:103
Bitrix\Main\Filter\Field\getDataItem
getDataItem($key)
Definition
field.php:162
Bitrix\Main\Filter\Field\getName
getName()
Definition
field.php:95
Bitrix\Main\Filter\Field\setDataProvider
setDataProvider(DataProvider $dataProvider)
Definition
field.php:55
Bitrix\Main\Filter\Field\isPartial
isPartial()
Definition
field.php:145
Bitrix\Main\Filter\Field\getSectionId
getSectionId()
Definition
field.php:171
Bitrix\Main\Filter\Field\__construct
__construct(DataProvider $dataProvider, $id, array $params=null)
Definition
field.php:24
Bitrix\Main\Filter\Field\markAsDefault
markAsDefault($isDefault)
Definition
field.php:135
Bitrix\Main\Filter\Field\prepareData
prepareData()
Definition
field.php:63
Bitrix\Main\Filter\Field\$isDefault
$isDefault
Definition
field.php:15
Bitrix\Main\Filter\Field\setIconParams
setIconParams(array $iconParams)
Definition
field.php:197
Bitrix\Main\Filter\Field\$iconParams
$iconParams
Definition
field.php:22
Bitrix\Main\Filter\Field\$data
$data
Definition
field.php:17
Bitrix\Main\Filter\Field\getData
getData()
Definition
field.php:153
Bitrix\Main\Filter\Field\getIconParams
getIconParams()
Definition
field.php:188
Bitrix\Main\Filter\Field\getType
getType()
Definition
field.php:111
Bitrix\Main\Filter\Field\setSectionId
setSectionId(string $sectionId)
Definition
field.php:180
Bitrix\Main\Filter\Field\$isPartial
$isPartial
Definition
field.php:19
Bitrix\Main\Filter\Field\$type
$type
Definition
field.php:13
Bitrix\Main\Filter\Field\getDataProvider
getDataProvider()
Definition
field.php:46
Bitrix\Main\Filter\Field\$dataProvider
$dataProvider
Definition
field.php:7
Bitrix\Main\Filter\Field\$name
$name
Definition
field.php:11
Bitrix\Main\Filter\Field\assemble
assemble()
Definition
field.php:207
Bitrix\Main\Filter\Field\$sectionId
$sectionId
Definition
field.php:21
Bitrix\Main\Filter\Field\setType
setType($type)
Definition
field.php:119
Bitrix\Main\Filter\Field\setID
setID($id)
Definition
field.php:87
Bitrix\Main\Filter\Field\toArray
toArray(array $options=null)
Definition
field.php:231
Bitrix\Main\Filter\Field\$id
$id
Definition
field.php:9
Bitrix\Main\Filter\Field\prepareHtml
prepareHtml()
Definition
field.php:71
Bitrix\Main\Filter
modules
main
lib
filter
field.php
Создано системой
1.10.0