1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
extension.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Engine\Response\Render;
4
5
use Bitrix\Main\Engine\Response\Render\Exception\InvalidConfigExtensionException;
6
use Bitrix\Main\Web\Json;
7
use CUtil;
8
9
final
class
Extension
extends
Base
10
{
11
public
function
__construct
(
12
private
string
$extension,
13
private
array
$params
= [],
14
bool
$withSiteTemplate =
true
,
15
)
16
{
17
parent::__construct($withSiteTemplate);
18
}
19
20
protected
function
renderContent
(): void
21
{
22
$html =
null
;
23
$controllerEntryPoint = $this->getControllerEntryPoint();
24
25
if
($controllerEntryPoint)
26
{
27
$containerId = uniqid(
'render_container_'
);
28
$selector = CUtil::JSEscape(
'#'
. $containerId);
29
30
$jsonParams = Json::encode($this->params);
31
32
$html = join(
''
, [
33
"<div id='{$containerId}'></div>"
,
34
"<script>BX.ready(() => { {$controllerEntryPoint}('{$selector}', {$jsonParams}) });</script>"
,
35
]);
36
}
37
else
38
{
39
throw
new
InvalidConfigExtensionException
(
40
$this->extension,
41
'`controllerEntrypoint` is not defined in extension config'
,
42
);
43
}
44
45
\Bitrix\Main\UI\Extension::load
($this->extension);
46
47
echo $html;
48
}
49
50
private
function
getControllerEntryPoint(): ?string
51
{
52
$config
=
\Bitrix\Main\UI\Extension::getConfig
($this->extension);
53
if
(isset(
$config
[
'controllerEntrypoint'
]))
54
{
55
if
(!is_string(
$config
[
'controllerEntrypoint'
]))
56
{
57
throw
new
InvalidConfigExtensionException
(
58
$this->extension,
59
'`controllerEntrypoint` in config must be a string with JS function name'
,
60
);
61
}
62
63
return
$config
[
'controllerEntrypoint'
];
64
}
65
66
return
null
;
67
}
68
}
Bitrix\Main\Engine\Response\Render\Base
Определения
base.php:10
Bitrix\Main\Engine\Response\Render\Exception\InvalidConfigExtensionException
Определения
invalidconfigextensionexception.php:6
Bitrix\Main\Engine\Response\Render\Extension
Определения
extension.php:10
Bitrix\Main\Engine\Response\Render\Extension\renderContent
renderContent()
Определения
extension.php:20
Bitrix\Main\Engine\Response\Render\Extension\__construct
__construct(private string $extension, private array $params=[], bool $withSiteTemplate=true,)
Определения
extension.php:11
Bitrix\Main\UI\Extension\load
static load($extNames)
Определения
extension.php:16
Bitrix\Main\UI\Extension\getConfig
static getConfig($extName)
Определения
extension.php:104
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$config
$config
Определения
quickway.php:69
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
main
lib
engine
response
render
extension.php
Создано системой
1.14.0