Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
package.php
1
<?php
2
3
namespace
Bitrix\Main\Web\WebPacker\Resource
;
4
10
class
Package
11
{
13
protected
$list
= [];
14
protected
$onDemand
=
false
;
15
21
public
static
function
getOrderedTypeList
()
22
{
23
return
[
24
Asset::CSS
,
25
Asset::LANG
,
26
Asset::LAYOUT
,
27
Asset::JS
,
28
];
29
}
30
36
public
function
__construct
(array $assets = [])
37
{
38
foreach
($assets as $asset)
39
{
40
$this->
addAsset
($asset);
41
}
42
}
43
50
public
function
addAsset
(
Asset
$item)
51
{
52
$this->list[] = $item;
53
return
$this;
54
}
55
62
public
function
getAssets
($type =
null
)
63
{
64
if
($type)
65
{
66
$list
= [];
67
foreach
($this->list as $asset)
68
{
69
if
($asset->getType() !== $type)
70
{
71
continue
;
72
}
73
74
$list
[] = $asset;
75
}
76
77
return
$list
;
78
}
79
80
return
$this->list
;
81
}
82
89
public
function
onDemand
()
90
{
91
$this->
onDemand
=
true
;
92
return
$this;
93
}
94
100
public
function
isOnDemand
()
101
{
102
return
$this->onDemand
;
103
}
104
111
public
function
toArray
($type =
null
)
112
{
113
$result = [];
114
foreach
($this->list as $asset)
115
{
116
if
($type && $asset->getType() != $type)
117
{
118
continue
;
119
}
120
121
$path = $asset->getUri();
122
if
($this->
onDemand
&& !$path)
123
{
124
continue
;
125
}
126
127
$content = $asset->getContent();
128
if
(!$this->
onDemand
&& !$content)
129
{
130
continue
;
131
}
132
133
$result[] = [
134
'type'
=> $asset->getType(),
135
'path'
=> $path,
136
'content'
=> $content,
137
'cache'
=>
true
,
138
];
139
}
140
141
return
$result;
142
}
143
}
Bitrix\Main\Web\WebPacker\Resource\Asset
Definition
asset.php:16
Bitrix\Main\Web\WebPacker\Resource\Asset\LANG
const LANG
Definition
asset.php:20
Bitrix\Main\Web\WebPacker\Resource\Asset\JS
const JS
Definition
asset.php:17
Bitrix\Main\Web\WebPacker\Resource\Asset\LAYOUT
const LAYOUT
Definition
asset.php:19
Bitrix\Main\Web\WebPacker\Resource\Asset\CSS
const CSS
Definition
asset.php:18
Bitrix\Main\Web\WebPacker\Resource\Package
Definition
package.php:11
Bitrix\Main\Web\WebPacker\Resource\Package\toArray
toArray($type=null)
Definition
package.php:111
Bitrix\Main\Web\WebPacker\Resource\Package\$onDemand
$onDemand
Definition
package.php:14
Bitrix\Main\Web\WebPacker\Resource\Package\onDemand
onDemand()
Definition
package.php:89
Bitrix\Main\Web\WebPacker\Resource\Package\isOnDemand
isOnDemand()
Definition
package.php:100
Bitrix\Main\Web\WebPacker\Resource\Package\getOrderedTypeList
static getOrderedTypeList()
Definition
package.php:21
Bitrix\Main\Web\WebPacker\Resource\Package\addAsset
addAsset(Asset $item)
Definition
package.php:50
Bitrix\Main\Web\WebPacker\Resource\Package\getAssets
getAssets($type=null)
Definition
package.php:62
Bitrix\Main\Web\WebPacker\Resource\Package\$list
$list
Definition
package.php:13
Bitrix\Main\Web\WebPacker\Resource\Package\__construct
__construct(array $assets=[])
Definition
package.php:36
Bitrix\Main\Web\WebPacker\Resource
Definition
asset.php:3
modules
main
lib
web
webpacker
resource
package.php
Создано системой
1.10.0