/
AssetInterface.php
254 lines (220 loc) · 6.26 KB
/
AssetInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
namespace Concrete\Core\Asset;
/**
* Interface that all the assets must implement.
*/
interface AssetInterface
{
/**
* Asset position: in the <head> tag.
*
* @var string
*/
const ASSET_POSITION_HEADER = 'H';
/**
* Asset position: at the end of the <body> tag.
*
* @var string
*/
const ASSET_POSITION_FOOTER = 'F';
/**
* Output asset type: CSS.
*
* @var string
*/
const OUTPUTASSETTYPE_CSS = 'javascript';
/**
* Output asset type: JavaScript.
*
* @var string
*/
const OUTPUTASSETTYPE_JAVASCRIPT = 'javascript';
/**
* QueryString parameter to avoid browser cache problems.
*
* @var string
*/
const OUTPUT_NOCACHE_PARAM = 'ccm_nocache';
/**
* Render the HTML tag that will load this asset.
*
* @return string
*/
public function __toString();
/**
* Get the default asset position (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).
*
* @return string
*/
public function getAssetDefaultPosition();
/**
* Set the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).
*
* @param string $position
*/
public function setAssetPosition($position);
/**
* Get the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).
*
* @return string
*/
public function getAssetPosition();
/**
* Get the unique identifier of the asset type.
*
* @return string
*/
public function getAssetType();
/**
* Get the handle of this asset (together with getAssetType, identifies this asset).
*
* @return string
*/
public function getAssetHandle();
/**
* Get the resulting type of the asset (\Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_CSS, \Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_JAVASCRIPT or other values).
*
* @return string
*/
public function getOutputAssetType();
/**
* Is this asset a locally available file (accessible with the getAssetPath method)?
*
* @param bool $isLocal
*/
public function setAssetIsLocal($isLocal);
/**
* Is this asset a locally available file (accessible with the getAssetPath method)?
*
* @return bool
*/
public function isAssetLocal();
/**
* Does this asset support minification?
*
* @param bool $minify
*/
public function setAssetSupportsMinification($minify);
/**
* Does this asset support minification?
*
* @return bool
*/
public function assetSupportsMinification();
/**
* Can this asset be combined with other assets?
*
* @param bool $combine
*/
public function setAssetSupportsCombination($combine);
/**
* Can this asset be combined with other assets?
*
* @return bool
*/
public function assetSupportsCombination();
/**
* Set the URL of this asset.
*
* @param string $url
*/
public function setAssetURL($url);
/**
* Get the URL of this asset.
*
* @return string
*/
public function getAssetURL();
/**
* Set the path to this asset.
*
* @param string $path
*/
public function setAssetPath($path);
/**
* Get the path to this asset.
*
* @return string
*/
public function getAssetPath();
/**
* If the asset is local, set its path and URL starting from the relative path. If it's not local, set its URL.
*
* @param string $path
*/
public function mapAssetLocation($path);
/**
* Get the path of the parent "folder" that contains this asset.
*
* @return string
*/
public function getAssetURLPath();
/**
* Get the name of the file of this asset.
*
* @return string
*/
public function getAssetFilename();
/**
* Get a string that unambiguously identifies this asset.
*
* @return string
*/
public function getAssetHashKey();
/**
* Set the version of this asset.
*
* @param string $version
*/
public function setAssetVersion($version);
/**
* Get the version of this asset.
*
* @return string
*/
public function getAssetVersion();
/**
* Set the package that defines this asset.
*
* @param \Concrete\Core\Package\Package|\Concrete\Core\Entity\Package|null|false $pkg
*/
public function setPackageObject($pkg);
/**
* Get the contents of the asset (if applicable).
*
* @return string|null
*/
public function getAssetContents();
/**
* Set the URL of the source files this asset has been built from (useful to understand the origin of this asset).
*
* @param string[] $paths
*/
public function setCombinedAssetSourceFiles($paths);
/**
* Register the asset properties.
*
* @param string $filename the location of the asset
* @param array $args {
*
* @var bool $local is this asset a locally available file (accessible with the getAssetPath method)?
* @var bool $minify does this asset support minification?
* @var bool $combine can this asset be combined with other assets?
* @var string $version the version of this asset
* @var string $position the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).
* }
*
* @param \Concrete\Core\Package\Package|\Concrete\Core\Entity\Package|string|null|false $pkg the package that defines this asset (or its handle)
*/
public function register($filename, $args, $pkg = false);
/**
* Asset-type specific post-processing.
*
* @param \Concrete\Core\Asset\AssetInterface[] $assets The original assets
*
* @return \Concrete\Core\Asset\AssetInterface[] The final assets
*
* @example Compress JavaScripts, merge CSS files...
*/
public static function process($assets);
}