1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Entity.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Marketplace\Application
;
4
5
use
Bitrix\Im\Color
;
6
use
Bitrix\Im\V2\Marketplace\Placement
;
7
use
Bitrix\Im\V2\Marketplace\Types\Context
;
8
use
Bitrix\Im\V2\Rest\RestEntity
;
9
10
class
Entity
implements
RestEntity
11
{
12
public
?
int
$id
=
null
;
13
public
?
string
$placement
=
null
;
14
public
?
string
$title
=
null
;
15
public
?
int
$restApplicationId
=
null
;
16
public
?
array
$options
=
null
;
17
public
?
int
$order
=
null
;
18
19
20
public
function
__construct
(?
array
$fields
=
null
)
21
{
22
if
(
$fields
!==
null
)
23
{
24
$this->
hydrate
(
$fields
);
25
}
26
}
27
28
public
function
hydrate
(
array
$fields
): void
29
{
30
$this->
id
= $fields[
'id'
] ??
null
;
31
$this->placement =
$fields
[
'placement'
] ??
null
;
32
$this->
title
=
$fields
[
'title'
] ??
null
;
33
$this->restApplicationId =
$fields
[
'restApplicationId'
] ??
null
;
34
$this->order =
$fields
[
'order'
] ??
null
;
35
$this->hydrateOptions((
$fields
[
'options'
] ??
null
));
36
}
37
38
private
function
hydrateOptions(?
array
$options
): void
39
{
40
if
(!
$options
)
41
{
42
return
;
43
}
44
45
if
(isset(
$options
[
'role'
]))
46
{
47
$this->options[
'role'
] = mb_strtolower(
$options
[
'role'
]);
48
}
49
if
(isset(
$options
[
'extranet'
]))
50
{
51
$this->options[
'extranet'
] =
$options
[
'extranet'
] ===
'Y'
?
'Y'
:
'N'
;
52
}
53
if
(isset(
$options
[
'context'
]))
54
{
55
$this->options[
'context'
] = $this->getContext(
$options
[
'context'
]);
56
}
57
if
(isset(
$options
[
'width'
]))
58
{
59
$this->options[
'width'
] =
$options
[
'width'
];
60
}
61
if
(isset(
$options
[
'height'
]))
62
{
63
$this->options[
'height'
] =
$options
[
'height'
];
64
}
65
if
(isset(
$options
[
'iconName'
]))
66
{
67
$this->options[
'iconName'
] =
$options
[
'iconName'
];
68
}
69
if
($this->placement ===
Placement::IM_TEXTAREA
|| $this->placement ===
Placement::IM_SIDEBAR
)
70
{
71
$this->options[
'color'
] =
Color::getColor
(
$options
[
'color'
]) ??
Color::getColorByNumber
($this->
id
);
72
}
73
}
74
75
private
function
getContext(
string
$contextOption):
array
76
{
77
$userContextList = explode(
';'
, trim($contextOption));
78
if
(in_array(
Context::ALL
, $userContextList,
true
))
79
{
80
return
[mb_strtolower(
Context::ALL
)];
81
}
82
83
return
array_map(
'mb_strtolower'
, $userContextList);
84
}
85
89
public
function
getId
(): ?int
90
{
91
return
$this->id
;
92
}
93
99
public
function
getTitle
(): ?string
100
{
101
return
$this->title
;
102
}
103
109
public
function
getOrder
(): ?int
110
{
111
return
$this->order
;
112
}
113
117
public
static
function
getRestEntityName
(): string
118
{
119
return
'placementApplication'
;
120
}
121
122
protected
function
toRestFormatOptions
():
array
123
{
124
$options
=
$this->options
;
125
if
(isset(
$options
[
'extranet'
]))
126
{
127
unset(
$options
[
'extranet'
]);
128
}
129
if
(isset(
$options
[
'role'
]))
130
{
131
unset(
$options
[
'role'
]);
132
}
133
134
return
$options
;
135
}
136
140
public
function
toRestFormat
(
array
$option
= []):
array
141
{
142
return
[
143
'id'
=> (int)$this->
id
,
144
'title'
=> $this->
title
,
145
'options'
=> $this->
toRestFormatOptions
(),
146
'placement'
=>
$this->placement
,
147
'order'
=>
$this->order
,
148
'loadConfiguration'
=> [
149
'ID'
=>
$this->restApplicationId
,
150
'PLACEMENT'
=>
$this->placement
,
151
'PLACEMENT_ID'
=>
$this->id
,
152
],
153
];
154
}
155
}
Bitrix\Im\Color\getColorByNumber
static getColorByNumber($number)
Определения
color.php:144
Bitrix\Im\Color\getColor
static getColor($code)
Определения
color.php:121
Bitrix\Im\V2\Marketplace\Application\Entity
Определения
Entity.php:11
Bitrix\Im\V2\Marketplace\Application\Entity\getRestEntityName
static getRestEntityName()
Определения
Entity.php:117
Bitrix\Im\V2\Marketplace\Application\Entity\getId
getId()
Определения
Entity.php:89
Bitrix\Im\V2\Marketplace\Application\Entity\toRestFormat
toRestFormat(array $option=[])
Определения
Entity.php:140
Bitrix\Im\V2\Marketplace\Application\Entity\$id
int $id
Определения
Entity.php:12
Bitrix\Im\V2\Marketplace\Application\Entity\getOrder
getOrder()
Определения
Entity.php:109
Bitrix\Im\V2\Marketplace\Application\Entity\$order
int $order
Определения
Entity.php:17
Bitrix\Im\V2\Marketplace\Application\Entity\$title
string $title
Определения
Entity.php:14
Bitrix\Im\V2\Marketplace\Application\Entity\getTitle
getTitle()
Определения
Entity.php:99
Bitrix\Im\V2\Marketplace\Application\Entity\$options
array $options
Определения
Entity.php:16
Bitrix\Im\V2\Marketplace\Application\Entity\toRestFormatOptions
toRestFormatOptions()
Определения
Entity.php:122
Bitrix\Im\V2\Marketplace\Application\Entity\$placement
string $placement
Определения
Entity.php:13
Bitrix\Im\V2\Marketplace\Application\Entity\$restApplicationId
int $restApplicationId
Определения
Entity.php:15
Bitrix\Im\V2\Marketplace\Application\Entity\hydrate
hydrate(array $fields)
Определения
Entity.php:28
Bitrix\Im\V2\Marketplace\Application\Entity\__construct
__construct(?array $fields=null)
Определения
Entity.php:20
Bitrix\Im\V2\Marketplace\Placement
Определения
Placement.php:6
Bitrix\Im\V2\Marketplace\Placement\IM_SIDEBAR
const IM_SIDEBAR
Определения
Placement.php:10
Bitrix\Im\V2\Marketplace\Placement\IM_TEXTAREA
const IM_TEXTAREA
Определения
Placement.php:9
Bitrix\Im\V2\Marketplace\Types\Context
Определения
Context.php:6
Bitrix\Im\V2\Marketplace\Types\Context\ALL
const ALL
Определения
Context.php:7
Bitrix\Main\ORM\Entity\$fields
$fields
Определения
entity.php:45
$options
$options
Определения
commerceml2.php:49
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Im\V2\Rest\RestEntity
Определения
RestEntity.php:8
Bitrix\Im\V2\Marketplace\Application
Определения
Entity.php:3
Bitrix\Im\V2\Message\Color
Определения
Color.php:3
title
<? endif;?> window document title
Определения
prolog_main_admin.php:76
$option
$option
Определения
options.php:1711
bitrix
modules
im
lib
V2
Marketplace
Application
Entity.php
Создано системой
1.14.0