1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
builder.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Landing\Assets
;
4
5
use
Bitrix\Main\ArgumentException
;
6
use
Bitrix\Main\ArgumentTypeException
;
7
use
Bitrix\Main
;
8
9
10
abstract
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
36
public
function
__construct
(
ResourceCollection
$resources
)
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
$type
Определения
options.php:106
Bitrix\Landing\Assets\Builder\setStrings
setStrings()
Определения
builder.php:119
Bitrix\Landing\Assets\Builder\__construct
__construct(ResourceCollection $resources)
Определения
builder.php:36
Bitrix\Landing\Assets\Builder\normalizeResources
normalizeResources()
Bitrix\Landing\Assets\Builder\initResourcesAsJsExtension
initResourcesAsJsExtension(array $resources, $extName=null)
Определения
builder.php:98
Bitrix\Landing\Assets\Builder\PACKAGE_NAME
const PACKAGE_NAME
Определения
builder.php:15
Bitrix\Landing\Assets\Builder\$normalizedResources
$normalizedResources
Определения
builder.php:24
Bitrix\Landing\Assets\Builder\createByType
static createByType(ResourceCollection $resources, string $type)
Определения
builder.php:55
Bitrix\Landing\Assets\Builder\TYPE_WEBPACK
const TYPE_WEBPACK
Определения
builder.php:13
Bitrix\Landing\Assets\Builder\setOutput
setOutput()
Bitrix\Landing\Assets\Builder\TYPE_STANDART
const TYPE_STANDART
Определения
builder.php:12
Bitrix\Landing\Assets\Builder\$landingId
$landingId
Определения
builder.php:29
Bitrix\Landing\Assets\Builder\$resources
$resources
Определения
builder.php:20
Bitrix\Landing\Assets\Builder\getOutput
getOutput()
Определения
builder.php:89
Bitrix\Landing\Assets\Builder\attachToLanding
attachToLanding(int $lid)
Определения
builder.php:74
Bitrix\Landing\Assets\ResourceCollection
Определения
resourcecollection.php:13
Bitrix\Landing\Assets\StandartBuilder
Определения
standartbuilder.php:11
Bitrix\Landing\Assets\WebpackBuilder
Определения
webpackbuilder.php:12
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
Bitrix\Main\ArgumentTypeException
Определения
ArgumentTypeException.php:9
Bitrix\Main\Web\WebPacker\Builder
Определения
builder.php:16
CJSCore\Init
static Init($arExt=array(), $bReturn=false)
Определения
jscore.php:66
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\Landing\Assets
Определения
builder.php:3
Bitrix\Main\Page
Определения
aliases.php:54
Bitrix\Main
bitrix
modules
landing
lib
assets
builder.php
Создано системой
1.14.0