@@ -45,14 +45,14 @@ |
||
| 45 | 45 | public static function fetchManifest(string $manifestPath) |
| 46 | 46 | { |
| 47 | 47 | // Grab the manifest |
| 48 | - $pathOrUrl = (string)Craft::parseEnv($manifestPath); |
|
| 48 | + $pathOrUrl = (string) Craft::parseEnv($manifestPath); |
|
| 49 | 49 | $manifest = FileHelper::fetch($pathOrUrl, [JsonHelper::class, 'decodeIfJson']); |
| 50 | 50 | // If no manifest file is found, log it |
| 51 | 51 | if ($manifest === null) { |
| 52 | - Craft::error('Manifest not found at ' . $manifestPath, __METHOD__); |
|
| 52 | + Craft::error('Manifest not found at '.$manifestPath, __METHOD__); |
|
| 53 | 53 | } |
| 54 | 54 | // Ensure we're dealing with an array |
| 55 | - self::$manifest = (array)$manifest; |
|
| 55 | + self::$manifest = (array) $manifest; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public static function fetch(string $pathOrUrl, callable $callback = null, string $cacheKeySuffix = '') |
| 56 | 56 | { |
| 57 | - $pathOrUrl = (string)Craft::parseEnv($pathOrUrl); |
|
| 57 | + $pathOrUrl = (string) Craft::parseEnv($pathOrUrl); |
|
| 58 | 58 | // Create the dependency tags |
| 59 | 59 | $dependency = new TagDependency([ |
| 60 | 60 | 'tags' => [ |
| 61 | - self::CACHE_TAG . $cacheKeySuffix, |
|
| 62 | - self::CACHE_TAG . $cacheKeySuffix . $pathOrUrl, |
|
| 61 | + self::CACHE_TAG.$cacheKeySuffix, |
|
| 62 | + self::CACHE_TAG.$cacheKeySuffix.$pathOrUrl, |
|
| 63 | 63 | ], |
| 64 | 64 | ]); |
| 65 | 65 | // If this is a file path such as for the `manifest.json`, add a FileDependency so it's cache bust if the file changes |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | // Get the result from the cache, or parse the file |
| 81 | 81 | $cache = Craft::$app->getCache(); |
| 82 | 82 | return $cache->getOrSet( |
| 83 | - self::CACHE_KEY . $cacheKeySuffix . $pathOrUrl, |
|
| 84 | - function () use ($pathOrUrl, $callback) { |
|
| 83 | + self::CACHE_KEY.$cacheKeySuffix.$pathOrUrl, |
|
| 84 | + function() use ($pathOrUrl, $callback) { |
|
| 85 | 85 | $contents = null; |
| 86 | 86 | $result = null; |
| 87 | 87 | if (UrlHelper::isAbsoluteUrl($pathOrUrl)) { |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public static function createUrl(string $url, string $path): string |
| 135 | 135 | { |
| 136 | - $url = (string)Craft::parseEnv($url); |
|
| 137 | - return rtrim($url, '/') . '/' . trim($path, '/'); |
|
| 136 | + $url = (string) Craft::parseEnv($url); |
|
| 137 | + return rtrim($url, '/').'/'.trim($path, '/'); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | $this->manifestShimsIncluded = true; |
| 217 | 217 | } |
| 218 | - foreach(array_merge($tags, $legacyTags) as $tag) { |
|
| 218 | + foreach (array_merge($tags, $legacyTags) as $tag) { |
|
| 219 | 219 | if (!empty($tag)) { |
| 220 | 220 | $url = FileHelper::createUrl($this->serverPublic, $tag['url']); |
| 221 | 221 | switch ($tag['type']) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $view->registerJsFile( |
| 277 | 277 | $url, |
| 278 | 278 | array_merge(['type' => 'module'], $scriptTagAttrs), |
| 279 | - md5($url . JsonHelper::encode($scriptTagAttrs)) |
|
| 279 | + md5($url.JsonHelper::encode($scriptTagAttrs)) |
|
| 280 | 280 | ); |
| 281 | 281 | // Include the react-refresh-shim |
| 282 | 282 | if ($this->includeReactRefreshShim) { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $view->registerJsFile( |
| 304 | 304 | $url, |
| 305 | 305 | array_merge(['type' => 'module'], $scriptTagAttrs), |
| 306 | - md5($url . JsonHelper::encode($scriptTagAttrs)) |
|
| 306 | + md5($url.JsonHelper::encode($scriptTagAttrs)) |
|
| 307 | 307 | ); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | $this->manifestShimsIncluded = true; |
| 341 | 341 | } |
| 342 | - foreach(array_merge($tags, $legacyTags) as $tag) { |
|
| 342 | + foreach (array_merge($tags, $legacyTags) as $tag) { |
|
| 343 | 343 | if (!empty($tag)) { |
| 344 | 344 | $url = FileHelper::createUrl($this->serverPublic, $tag['url']); |
| 345 | 345 | switch ($tag['type']) { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $view->registerJsFile( |
| 348 | 348 | $url, |
| 349 | 349 | $tag['options'], |
| 350 | - md5($url . JsonHelper::encode($tag['options'])) |
|
| 350 | + md5($url.JsonHelper::encode($tag['options'])) |
|
| 351 | 351 | ); |
| 352 | 352 | break; |
| 353 | 353 | case 'css': |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | public function invalidateCaches() |
| 406 | 406 | { |
| 407 | 407 | $cache = Craft::$app->getCache(); |
| 408 | - TagDependency::invalidate($cache, FileHelper::CACHE_TAG . $this->cacheKeySuffix); |
|
| 408 | + TagDependency::invalidate($cache, FileHelper::CACHE_TAG.$this->cacheKeySuffix); |
|
| 409 | 409 | Craft::info('All Vite caches cleared', __METHOD__); |
| 410 | 410 | } |
| 411 | 411 | |