1 | <?php |
||
18 | class Vasri |
||
19 | { |
||
20 | |||
21 | |||
22 | /** |
||
23 | * @var Builder |
||
24 | */ |
||
25 | private $builder; |
||
26 | |||
27 | /** |
||
28 | * @var ManifestReader |
||
29 | */ |
||
30 | private $manifestReader; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $vasriManifest; |
||
36 | |||
37 | /** |
||
38 | * @var mixed |
||
39 | */ |
||
40 | private $appEnvironment; |
||
41 | |||
42 | /** |
||
43 | * @var |
||
44 | */ |
||
45 | private $vasriConfig; |
||
46 | |||
47 | /** |
||
48 | * @var |
||
49 | */ |
||
50 | private $isMixManifestAltEnabled; |
||
51 | |||
52 | /** |
||
53 | * Vasri constructor. |
||
54 | */ |
||
55 | public function __construct() |
||
64 | |||
65 | /** |
||
66 | * The Vasri helper function |
||
67 | * |
||
68 | * @param string $file |
||
69 | * @param bool $enableVersioning |
||
70 | * @param bool $enableSRI |
||
71 | * |
||
72 | * @param string $keyword |
||
73 | * |
||
74 | * @return string |
||
75 | * @throws Exception |
||
76 | */ |
||
77 | public function vasri( |
||
102 | |||
103 | /** |
||
104 | * Fetches the SRI hash from the Vasri Manifest and adds the crossorigin attribute |
||
105 | * |
||
106 | * @param string $file |
||
107 | * |
||
108 | * @param string $keyword |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | private function getSRI(string $file, string $keyword): string |
||
117 | |||
118 | /** |
||
119 | * Builds all the attributes |
||
120 | * |
||
121 | * @param string $file |
||
122 | * @param string $altFile |
||
123 | * @param bool $enableVersioning |
||
124 | * |
||
125 | * @param bool $enableSRI |
||
126 | * @param string $keyword |
||
127 | * |
||
128 | * @return string |
||
129 | * @throws Exception |
||
130 | */ |
||
131 | private function addAttributes( |
||
162 | |||
163 | /** |
||
164 | * Fetches the version query string from the Vasri Manifest |
||
165 | * |
||
166 | * @param string $file |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | private function getVersioning(string $file): string |
||
174 | |||
175 | /** |
||
176 | * Figures out whether or not to toggle versioning and sri |
||
177 | * |
||
178 | * @param bool $enableVersioning |
||
179 | * @param bool $enableSRI |
||
180 | * |
||
181 | * @return array |
||
182 | */ |
||
183 | private function getOptions(bool $enableVersioning, bool $enableSRI): array |
||
194 | |||
195 | /** |
||
196 | * Gets source attribute based on the extension, adds file path and version |
||
197 | * |
||
198 | * @param string $file |
||
199 | * @param string $version |
||
200 | * |
||
201 | * @return string |
||
202 | * @throws Exception |
||
203 | */ |
||
204 | private function getSourceAttribute(string $file, string $version = ''): string |
||
208 | |||
209 | /** |
||
210 | * Checks if the file is in the Laravel public path |
||
211 | * |
||
212 | * @param string $file |
||
213 | * |
||
214 | * @return bool |
||
215 | */ |
||
216 | private static function isPublicFile(string $file): bool |
||
220 | |||
221 | } |
||
222 |