@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | 'rev-manifest.json', |
24 | 24 | ], |
25 | 25 | 'missingAsset' => 'notice', // exception, notice, or ignore |
26 | - 'missingManifest' => 'notice', // exception, notice, or ignore |
|
26 | + 'missingManifest' => 'notice', // exception, notice, or ignore |
|
27 | 27 | 'missingVersion' => 'ignore', // exception, notice, or ignore |
28 | 28 | ]; |
29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $choices = ['exception', 'notice', 'ignore']; |
36 | 36 | $this->validateChoices('missingAsset', $choices); |
37 | - $this->validateChoices('missingManifest', $choices); |
|
37 | + $this->validateChoices('missingManifest', $choices); |
|
38 | 38 | $this->validateChoices('missingVersion', $choices); |
39 | 39 | |
40 | 40 | $builder = $this->getContainerBuilder(); |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | // Get asset version |
76 | - try { |
|
77 | - $versions = $config['revManifest'] ?: |
|
78 | - self::autodetectVersions($absolutePath, $wwwDir, $config['autodetect']); |
|
79 | - $version = self::getAssetVersion($versions, $absolutePath, $needed, $config); |
|
80 | - } catch(ManifestNotFoundException $e) { |
|
81 | - self::throwError($e, $config['missingManifest'], $needed); |
|
82 | - $version = 'unknown'; |
|
83 | - } |
|
76 | + try { |
|
77 | + $versions = $config['revManifest'] ?: |
|
78 | + self::autodetectVersions($absolutePath, $wwwDir, $config['autodetect']); |
|
79 | + $version = self::getAssetVersion($versions, $absolutePath, $needed, $config); |
|
80 | + } catch(ManifestNotFoundException $e) { |
|
81 | + self::throwError($e, $config['missingManifest'], $needed); |
|
82 | + $version = 'unknown'; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | return self::formatOutput($format, $basePath, $relativePath, $version); |
86 | 86 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | switch ($matches[1]) { |
103 | 103 | case 'url': |
104 | 104 | return sprintf("%s/%s?v=%s", $basePath, $relativePath, $version); |
105 | - case 'path': |
|
106 | - return sprintf("%s/%s", $basePath, $relativePath); |
|
105 | + case 'path': |
|
106 | + return sprintf("%s/%s", $basePath, $relativePath); |
|
107 | 107 | case 'version': |
108 | 108 | return $version; |
109 | 109 | case 'basePath': |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | if (($absolutePath = realpath($wwwDir . DIRECTORY_SEPARATOR . $relativePath)) === FALSE) { |
160 | - $msg = sprintf("Asset '%s' not found.", $relativePath); |
|
161 | - self::throwError(new AssetNotFoundException($msg), $config['missingAsset'], $needed); |
|
160 | + $msg = sprintf("Asset '%s' not found.", $relativePath); |
|
161 | + self::throwError(new AssetNotFoundException($msg), $config['missingAsset'], $needed); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | return [$relativePath, $absolutePath, $wwwDir]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * @param mixed $assetsVersions |
170 | 170 | * @param string $absolutePath |
171 | - * @param bool $needed |
|
171 | + * @param bool $needed |
|
172 | 172 | * @param array $config |
173 | 173 | * @return mixed|string |
174 | 174 | */ |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | $msg = sprintf("Asset macro: version of asset '%s' not found.", $absolutePath); |
193 | - self::throwError(new AssetVersionNotFound($msg), $config['missingVersion'], $needed); |
|
193 | + self::throwError(new AssetVersionNotFound($msg), $config['missingVersion'], $needed); |
|
194 | 194 | |
195 | - return 'unknown'; |
|
195 | + return 'unknown'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
199 | - /** |
|
200 | - * @param $absolutePath |
|
201 | - * @param $wwwDir |
|
202 | - * @param array $paths |
|
203 | - * @return mixed|string |
|
204 | - */ |
|
199 | + /** |
|
200 | + * @param $absolutePath |
|
201 | + * @param $wwwDir |
|
202 | + * @param array $paths |
|
203 | + * @return mixed|string |
|
204 | + */ |
|
205 | 205 | private static function autodetectVersions($absolutePath, $wwwDir, array $paths) |
206 | 206 | { |
207 | 207 | // Iterate over parent directories (stop in www dir) |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | ); |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * @param \Exception $e |
|
231 | - * @param string $action |
|
232 | - * @param bool $needed |
|
233 | - * @throws \Exception |
|
234 | - */ |
|
229 | + /** |
|
230 | + * @param \Exception $e |
|
231 | + * @param string $action |
|
232 | + * @param bool $needed |
|
233 | + * @throws \Exception |
|
234 | + */ |
|
235 | 235 | private static function throwError(\Exception $e, $action = 'exception', $needed = TRUE) { |
236 | - if ($needed) { |
|
237 | - if ($action === 'exception') { |
|
238 | - throw $e; |
|
239 | - } elseif ($action === 'notice') { |
|
240 | - trigger_error($e->getMessage(), E_USER_NOTICE); |
|
241 | - } |
|
242 | - } |
|
243 | - } |
|
236 | + if ($needed) { |
|
237 | + if ($action === 'exception') { |
|
238 | + throw $e; |
|
239 | + } elseif ($action === 'notice') { |
|
240 | + trigger_error($e->getMessage(), E_USER_NOTICE); |
|
241 | + } |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | } |