1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
entitylink.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\Link\Html
;
4
5
use Bitrix\Crm\Service\Container;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Text\HtmlFilter
;
8
use CCrmOwnerType;
9
10
Loader::requireModule(
'crm'
);
11
15
class
EntityLink
16
{
17
private
int
$entityTypeId;
18
private
int
$entityId;
19
private
string
$href;
20
26
public
function
__construct
(
int
$entityTypeId,
int
$entityId,
string
$href)
27
{
28
$this->entityTypeId = $entityTypeId;
29
$this->entityId = $entityId;
30
$this->href = $href;
31
}
32
45
public
static
function
createByOrder
(
int
$orderId
,
string
$link): self
46
{
47
$entityId =
$orderId
;
48
$entityTypeId = CCrmOwnerType::Undefined;
49
50
$order
= \Bitrix\Crm\Order\Order::load(
$orderId
);
51
if
(
$order
)
52
{
53
$binding =
$order
->getEntityBinding();
54
if
($binding)
55
{
56
$entityId = $binding->getOwnerId();
57
$entityTypeId = $binding->getOwnerTypeId();
58
}
59
else
60
{
61
$entityId =
$orderId
;
62
$entityTypeId = CCrmOwnerType::Order;
63
}
64
}
65
66
return
new
static
($entityTypeId, $entityId, $link);
67
}
68
74
private
function
getLabel(): string
75
{
76
// we process orders separately, because the factory does not know how to work with items.
77
if
($this->entityTypeId === CCrmOwnerType::Order)
78
{
79
$description
= CCrmOwnerType::GetDescription($this->entityTypeId);
80
81
return
"{$description} #{$this->entityId}"
;
82
}
83
84
$factory = Container::getInstance()->getFactory($this->entityTypeId);
85
if
($factory)
86
{
87
$item = $factory->getItem($this->entityId);
88
if
($item)
89
{
90
$title
= $item->getHeading();
91
if
(
$title
)
92
{
93
return
$title
;
94
}
95
}
96
}
97
98
return
$this->entityId
;
99
}
100
106
public
function
render
(): string
107
{
108
$href =
HtmlFilter::encode
($this->href);
109
110
$sanitizer = new \CBXSanitizer();
111
$sanitizer->setLevel(\
CBXSanitizer::SECURE_LEVEL_HIGH
);
112
$sanitizer->ApplyDoubleEncode(
false
);
113
114
$label = $sanitizer->SanitizeHtml($this->getLabel());
115
116
unset($sanitizer);
117
118
if
(!$href)
119
{
120
return
$label;
121
}
122
123
return
'<a href="'
. $href .
'">'
. $label .
'</a>'
;
124
}
125
}
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Text\HtmlFilter
Определения
htmlfilter.php:11
Bitrix\Main\Text\HtmlFilter\encode
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
htmlfilter.php:12
Bitrix\Sale\Link\Html\EntityLink
Определения
entitylink.php:16
Bitrix\Sale\Link\Html\EntityLink\createByOrder
static createByOrder(int $orderId, string $link)
Определения
entitylink.php:45
Bitrix\Sale\Link\Html\EntityLink\__construct
__construct(int $entityTypeId, int $entityId, string $href)
Определения
entitylink.php:26
Bitrix\Sale\Link\Html\EntityLink\render
render()
Определения
entitylink.php:106
CBXSanitizer\SECURE_LEVEL_HIGH
const SECURE_LEVEL_HIGH
Определения
sanitizer.php:28
$orderId
$orderId
Определения
payment.php:5
$description
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения
.description.php:24
Bitrix\Sale\Link\Html
Определения
entitylink.php:3
$order
$order
Определения
payment.php:8
$entityId
$entityId
Определения
payment.php:4
$title
$title
Определения
pdf.php:123
bitrix
modules
sale
lib
link
html
entitylink.php
Создано системой
1.14.0