@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | Event::on( |
108 | 108 | View::class, |
109 | 109 | View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, |
110 | - function (TemplateEvent $event) { |
|
110 | + function(TemplateEvent $event) { |
|
111 | 111 | self::$templateName = $event->template; |
112 | 112 | } |
113 | 113 | ); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | Event::on( |
116 | 116 | CraftVariable::class, |
117 | 117 | CraftVariable::EVENT_INIT, |
118 | - function (Event $event) { |
|
118 | + function(Event $event) { |
|
119 | 119 | /** @var CraftVariable $variable */ |
120 | 120 | $variable = $event->sender; |
121 | 121 | $variable->set('twigpack', ManifestVariable::class); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | Event::on( |
126 | 126 | TemplateCaches::class, |
127 | 127 | TemplateCaches::EVENT_AFTER_DELETE_CACHES, |
128 | - function (DeleteTemplateCachesEvent $event) { |
|
128 | + function(DeleteTemplateCachesEvent $event) { |
|
129 | 129 | // Invalidate the caches when template caches are deleted |
130 | 130 | $this->clearAllCaches(); |
131 | 131 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | Event::on( |
135 | 135 | Plugins::class, |
136 | 136 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
137 | - function (PluginEvent $event) { |
|
137 | + function(PluginEvent $event) { |
|
138 | 138 | if ($event->plugin === $this) { |
139 | 139 | // Invalidate our caches after we've been installed |
140 | 140 | $this->clearAllCaches(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | Event::on( |
146 | 146 | ClearCaches::class, |
147 | 147 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
148 | - function (RegisterCacheOptionsEvent $event) { |
|
148 | + function(RegisterCacheOptionsEvent $event) { |
|
149 | 149 | Craft::debug( |
150 | 150 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
151 | 151 | __METHOD__ |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | // delay attaching event handler to the view component after it is fully configured |
161 | 161 | $app = Craft::$app; |
162 | 162 | if ($app->getConfig()->getGeneral()->devMode) { |
163 | - $app->on(Application::EVENT_BEFORE_REQUEST, function () use ($app) { |
|
163 | + $app->on(Application::EVENT_BEFORE_REQUEST, function() use ($app) { |
|
164 | 164 | $app->getView()->on(View::EVENT_END_BODY, [$this, 'injectErrorEntry']); |
165 | 165 | }); |
166 | 166 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | 'errorEntry' => '', |
33 | 33 | // String to be appended to the cache key |
34 | 34 | 'cacheKeySuffix' => '', |
35 | - // Manifest file names |
|
35 | + // Manifest file names |
|
36 | 36 | 'manifest' => [ |
37 | 37 | 'legacy' => 'manifest-legacy.json', |
38 | 38 | 'modern' => 'manifest.json', |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $dirPrefix = CRAFT_TEMPLATES_PATH; |
114 | 114 | } |
115 | 115 | $name = strstr($name, $dirPrefix); |
116 | - $name = (string)str_replace($dirPrefix, '', $name); |
|
116 | + $name = (string) str_replace($dirPrefix, '', $name); |
|
117 | 117 | $path = self::combinePaths( |
118 | 118 | $config['localFiles']['basePath'], |
119 | 119 | $config['localFiles']['criticalPrefix'], |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | // Otherwise, try not-hot files |
369 | - $localPrefix = $config['localFiles']['basePath'] . $config['localFiles']['criticalPrefix']; |
|
369 | + $localPrefix = $config['localFiles']['basePath'].$config['localFiles']['criticalPrefix']; |
|
370 | 370 | $localPath = self::combinePaths( |
371 | 371 | $localPrefix, |
372 | 372 | $path |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $cacheKeySuffix = $settings->cacheKeySuffix ?? ''; |
477 | 477 | $file = $cache->getOrSet( |
478 | 478 | self::CACHE_KEY.$cacheKeySuffix.$path, |
479 | - function () use ($path, $callback) { |
|
479 | + function() use ($path, $callback) { |
|
480 | 480 | $result = null; |
481 | 481 | if (UrlHelper::isAbsoluteUrl($path)) { |
482 | 482 | /** |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | protected static function combinePaths(string ...$paths): string |
526 | 526 | { |
527 | 527 | $last_key = count($paths) - 1; |
528 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
528 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
529 | 529 | switch ($key) { |
530 | 530 | case 0: |
531 | 531 | $val = rtrim($val, '/ '); |
@@ -243,39 +243,39 @@ |
||
243 | 243 | return $module; |
244 | 244 | } |
245 | 245 | |
246 | - /** |
|
247 | - * Return the HASH value from to module |
|
248 | - * |
|
249 | - * @param array $config |
|
250 | - * @param string $moduleName |
|
251 | - * @param string $type |
|
252 | - * @param bool $soft |
|
253 | - * |
|
254 | - * @return null|string |
|
255 | - * @throws NotFoundHttpException |
|
256 | - */ |
|
257 | - public static function getModuleHash(array $config, string $moduleName, string $type = 'modern', bool $soft = false) |
|
258 | - { |
|
259 | - |
|
260 | - try { |
|
261 | - // Get the module entry |
|
262 | - $module = self::getModuleEntry($config, $moduleName, $type, $soft); |
|
263 | - if ($module !== null) { |
|
264 | - $prefix = self::$isHot |
|
265 | - ? $config['devServer']['publicPath'] |
|
266 | - : $config['server']['publicPath']; |
|
267 | - // Extract only the Hash Value |
|
268 | - $modulePath = pathinfo($module); |
|
269 | - $moduleFilename = $modulePath['filename']; |
|
270 | - $moduleHash = substr($moduleFilename, strpos($moduleFilename, ".") + 1); |
|
271 | - } |
|
272 | - } catch (Exception $e) { |
|
273 | - // return emtpt string if no module is found |
|
274 | - return ''; |
|
275 | - } |
|
276 | - |
|
277 | - return $moduleHash; |
|
278 | - } |
|
246 | + /** |
|
247 | + * Return the HASH value from to module |
|
248 | + * |
|
249 | + * @param array $config |
|
250 | + * @param string $moduleName |
|
251 | + * @param string $type |
|
252 | + * @param bool $soft |
|
253 | + * |
|
254 | + * @return null|string |
|
255 | + * @throws NotFoundHttpException |
|
256 | + */ |
|
257 | + public static function getModuleHash(array $config, string $moduleName, string $type = 'modern', bool $soft = false) |
|
258 | + { |
|
259 | + |
|
260 | + try { |
|
261 | + // Get the module entry |
|
262 | + $module = self::getModuleEntry($config, $moduleName, $type, $soft); |
|
263 | + if ($module !== null) { |
|
264 | + $prefix = self::$isHot |
|
265 | + ? $config['devServer']['publicPath'] |
|
266 | + : $config['server']['publicPath']; |
|
267 | + // Extract only the Hash Value |
|
268 | + $modulePath = pathinfo($module); |
|
269 | + $moduleFilename = $modulePath['filename']; |
|
270 | + $moduleHash = substr($moduleFilename, strpos($moduleFilename, ".") + 1); |
|
271 | + } |
|
272 | + } catch (Exception $e) { |
|
273 | + // return emtpt string if no module is found |
|
274 | + return ''; |
|
275 | + } |
|
276 | + |
|
277 | + return $moduleHash; |
|
278 | + } |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * Return a module's raw entry from the manifest |
@@ -119,22 +119,22 @@ |
||
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Return the HASH value from a module |
|
124 | - * |
|
125 | - * @param string $moduleName |
|
126 | - * @param string $type |
|
127 | - * @param null $config |
|
128 | - * |
|
129 | - * @return null|Markup |
|
130 | - * @throws NotFoundHttpException |
|
131 | - */ |
|
132 | - public function getModuleHash(string $moduleName, string $type = 'modern', $config = null) |
|
133 | - { |
|
134 | - return Template::raw( |
|
135 | - Twigpack::$plugin->manifest->getModuleHash($moduleName, $type, $config) |
|
136 | - ); |
|
137 | - } |
|
122 | + /** |
|
123 | + * Return the HASH value from a module |
|
124 | + * |
|
125 | + * @param string $moduleName |
|
126 | + * @param string $type |
|
127 | + * @param null $config |
|
128 | + * |
|
129 | + * @return null|Markup |
|
130 | + * @throws NotFoundHttpException |
|
131 | + */ |
|
132 | + public function getModuleHash(string $moduleName, string $type = 'modern', $config = null) |
|
133 | + { |
|
134 | + return Template::raw( |
|
135 | + Twigpack::$plugin->manifest->getModuleHash($moduleName, $type, $config) |
|
136 | + ); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Include the Safari 10.1 nomodule fix JavaScript |
@@ -131,25 +131,25 @@ |
||
131 | 131 | return ManifestHelper::getModule($config, $moduleName, $type); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Return the HASH value from a module |
|
136 | - * |
|
137 | - * @param string $moduleName |
|
138 | - * @param string $type |
|
139 | - * @param null $config |
|
140 | - * |
|
141 | - * @return null|string |
|
142 | - * @throws NotFoundHttpException |
|
143 | - */ |
|
144 | - public function getModuleHash(string $moduleName, string $type = 'modern', $config = null) |
|
145 | - { |
|
146 | - $settings = Twigpack::$plugin->getSettings(); |
|
147 | - $config = $config ?? $settings->getAttributes(); |
|
148 | - |
|
149 | - return ManifestHelper::getModuleHash($config, $moduleName, $type); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
134 | + /** |
|
135 | + * Return the HASH value from a module |
|
136 | + * |
|
137 | + * @param string $moduleName |
|
138 | + * @param string $type |
|
139 | + * @param null $config |
|
140 | + * |
|
141 | + * @return null|string |
|
142 | + * @throws NotFoundHttpException |
|
143 | + */ |
|
144 | + public function getModuleHash(string $moduleName, string $type = 'modern', $config = null) |
|
145 | + { |
|
146 | + $settings = Twigpack::$plugin->getSettings(); |
|
147 | + $config = $config ?? $settings->getAttributes(); |
|
148 | + |
|
149 | + return ManifestHelper::getModuleHash($config, $moduleName, $type); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | 153 | * Returns the contents of a file from a URI path |
154 | 154 | * |
155 | 155 | * @param string $path |