1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
builder.php
См. документацию.
1<?php
2
4
8
9
10abstract class Builder
11{
12 protected const TYPE_STANDART = 'STANDART';
13 protected const TYPE_WEBPACK = 'WEBPACK';
14
15 protected const PACKAGE_NAME = 'landing_assets';
16
20 protected $resources;
24 protected $normalizedResources = [];
29 protected $landingId = 0;
30
37 {
38 if ($resources instanceof ResourceCollection)
39 {
40 $this->resources = $resources;
41 }
42 else
43 {
44 throw new ArgumentTypeException($resources, 'ResourceCollection');
45 }
46 }
47
55 public static function createByType(ResourceCollection $resources, string $type): ?Builder
56 {
57 switch ($type)
58 {
59 case self::TYPE_STANDART:
60 return new StandartBuilder($resources);
61
62 case self::TYPE_WEBPACK:
63 return new WebpackBuilder($resources);
64
65 default:
66 throw new ArgumentException("Unknown landing asset builder type `$type`.");
67 }
68 }
69
74 public function attachToLanding(int $lid): void
75 {
76 $this->landingId = (int)$lid;
77 }
78
83 abstract public function setOutput();
84
89 public function getOutput(): array
90 {
91 $this->normalizeResources();
92
93 return $this->normalizedResources;
94 }
95
96 abstract protected function normalizeResources();
97
98 protected function initResourcesAsJsExtension(array $resources, $extName = null): void
99 {
100 if (!$extName)
101 {
102 $extName = self::PACKAGE_NAME;
103 }
104 $extFullName = $extName . '_' . md5(serialize($resources));
105
106 $resources = array_merge($resources, [
107 'bundle_js' => $extFullName,
108 'bundle_css' => $extFullName,
109 'skip_core' => true,
110 ]);
112 \CJSCore::registerExt($extName, $resources);
113 \CJSCore::Init($extName);
114 }
115
119 protected function setStrings(): void
120 {
121 foreach ($this->resources->getStrings() as $string)
122 {
123 Main\Page\Asset::getInstance()->addString($string, false, Main\Page\AssetLocation::AFTER_JS);
124 }
125 }
126}
$type
Определения options.php:106
__construct(ResourceCollection $resources)
Определения builder.php:36
initResourcesAsJsExtension(array $resources, $extName=null)
Определения builder.php:98
const PACKAGE_NAME
Определения builder.php:15
$normalizedResources
Определения builder.php:24
static createByType(ResourceCollection $resources, string $type)
Определения builder.php:55
const TYPE_WEBPACK
Определения builder.php:13
const TYPE_STANDART
Определения builder.php:12
attachToLanding(int $lid)
Определения builder.php:74
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения builder.php:3
Определения aliases.php:54