1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
extension.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Engine\Response\Render;
4
5use Bitrix\Main\Engine\Response\Render\Exception\InvalidConfigExtensionException;
6use Bitrix\Main\Web\Json;
7use CUtil;
8
9final 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 {
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 {
53 if (isset($config['controllerEntrypoint']))
54 {
55 if (!is_string($config['controllerEntrypoint']))
56 {
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}
__construct(private string $extension, private array $params=[], bool $withSiteTemplate=true,)
Определения extension.php:11
static load($extNames)
Определения extension.php:16
static getConfig($extName)
Определения extension.php:104
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$config
Определения quickway.php:69
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799