@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | $this->defaults = $defaults; |
117 | 117 | $this->serverRoot = $serverRoot; |
118 | 118 | $this->cacheFactory = $cacheFactory; |
119 | - $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl())); |
|
120 | - $this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl())); |
|
121 | - $lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl())); |
|
119 | + $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-'.md5($this->urlGenerator->getBaseUrl())); |
|
120 | + $this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-'.md5($this->urlGenerator->getBaseUrl())); |
|
121 | + $lockingCache = $cacheFactory->createDistributed('SCSS-locks-'.md5($this->urlGenerator->getBaseUrl())); |
|
122 | 122 | if (!($lockingCache instanceof IMemcache)) { |
123 | 123 | $lockingCache = new NullCache(); |
124 | 124 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @throws NotPermittedException |
138 | 138 | */ |
139 | 139 | public function process(string $root, string $file, string $app): bool { |
140 | - $path = explode('/', $root . '/' . $file); |
|
140 | + $path = explode('/', $root.'/'.$file); |
|
141 | 141 | |
142 | 142 | $fileNameSCSS = array_pop($path); |
143 | 143 | $fileNameCSS = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)), $app); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $folder = $this->appData->newFolder($app); |
158 | 158 | } |
159 | 159 | |
160 | - $lockKey = $webDir . '/' . $fileNameSCSS; |
|
160 | + $lockKey = $webDir.'/'.$fileNameSCSS; |
|
161 | 161 | |
162 | 162 | if (!$this->lockingCache->add($lockKey, 'locked!', 120)) { |
163 | 163 | $retry = 0; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) { |
167 | 167 | // Inject icons vars css if any |
168 | 168 | $this->lockingCache->remove($lockKey); |
169 | - $this->logger->debug('SCSSCacher: ' .$lockKey.' is now available after '.$retry.'s. Moving on...', ['app' => 'core']); |
|
169 | + $this->logger->debug('SCSSCacher: '.$lockKey.' is now available after '.$retry.'s. Moving on...', ['app' => 'core']); |
|
170 | 170 | return $this->injectCssVariablesIfAny(); |
171 | 171 | } |
172 | 172 | $this->logger->debug('SCSSCacher: scss cache file locked for '.$lockKey, ['app' => 'core']); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return boolean |
215 | 215 | */ |
216 | 216 | private function isCached(string $fileNameCSS, string $app) { |
217 | - $key = $this->config->getSystemValue('version') . '/' . $app . '/' . $fileNameCSS; |
|
217 | + $key = $this->config->getSystemValue('version').'/'.$app.'/'.$fileNameCSS; |
|
218 | 218 | |
219 | 219 | // If the file mtime is more recent than our cached one, |
220 | 220 | // let's consider the file is properly cached |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | try { |
237 | 237 | $cachedFile = $folder->getFile($fileNameCSS); |
238 | 238 | if ($cachedFile->getSize() > 0) { |
239 | - $depFileName = $fileNameCSS . '.deps'; |
|
240 | - $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName); |
|
239 | + $depFileName = $fileNameCSS.'.deps'; |
|
240 | + $deps = $this->depsCache->get($folder->getName().'-'.$depFileName); |
|
241 | 241 | if ($deps === null) { |
242 | 242 | $depFile = $folder->getFile($depFileName); |
243 | 243 | $deps = $depFile->getContent(); |
244 | 244 | // Set to memcache for next run |
245 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
245 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
246 | 246 | } |
247 | 247 | $deps = json_decode($deps, true); |
248 | 248 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $scss = new Compiler(); |
292 | 292 | $scss->setImportPaths([ |
293 | 293 | $path, |
294 | - $this->serverRoot . '/core/css/' |
|
294 | + $this->serverRoot.'/core/css/' |
|
295 | 295 | ]); |
296 | 296 | |
297 | 297 | // Continue after throw |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $cachedfile = $folder->newFile($fileNameCSS); |
312 | 312 | } |
313 | 313 | |
314 | - $depFileName = $fileNameCSS . '.deps'; |
|
314 | + $depFileName = $fileNameCSS.'.deps'; |
|
315 | 315 | try { |
316 | 316 | $depFile = $folder->getFile($depFileName); |
317 | 317 | } catch (NotFoundException $e) { |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | // Compile |
322 | 322 | try { |
323 | 323 | $compiledScss = $scss->compile( |
324 | - '$webroot: \'' . $this->getRoutePrefix() . '\';' . |
|
325 | - $this->getInjectedVariables() . |
|
326 | - '@import "variables.scss";' . |
|
327 | - '@import "functions.scss";' . |
|
328 | - '@import "' . $fileNameSCSS . '";'); |
|
324 | + '$webroot: \''.$this->getRoutePrefix().'\';'. |
|
325 | + $this->getInjectedVariables(). |
|
326 | + '@import "variables.scss";'. |
|
327 | + '@import "functions.scss";'. |
|
328 | + '@import "'.$fileNameSCSS.'";'); |
|
329 | 329 | } catch (ParserException $e) { |
330 | 330 | $this->logger->logException($e, ['app' => 'core']); |
331 | 331 | |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | |
338 | 338 | // Gzip file |
339 | 339 | try { |
340 | - $gzipFile = $folder->getFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz |
|
340 | + $gzipFile = $folder->getFile($fileNameCSS.'.gzip'); # Safari doesn't like .gz |
|
341 | 341 | } catch (NotFoundException $e) { |
342 | - $gzipFile = $folder->newFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz |
|
342 | + $gzipFile = $folder->newFile($fileNameCSS.'.gzip'); # Safari doesn't like .gz |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | try { |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | $cachedfile->putContent($data); |
348 | 348 | $deps = json_encode($scss->getParsedFiles()); |
349 | 349 | $depFile->putContent($deps); |
350 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
350 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
351 | 351 | $gzipFile->putContent(gzencode($data, 9)); |
352 | - $this->logger->debug('SCSSCacher: ' . $webDir . '/' . $fileNameSCSS . ' compiled and successfully cached', ['app' => 'core']); |
|
352 | + $this->logger->debug('SCSSCacher: '.$webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
|
353 | 353 | |
354 | 354 | return true; |
355 | 355 | } catch (NotPermittedException $e) { |
356 | - $this->logger->error('SCSSCacher: unable to cache: ' . $fileNameSCSS); |
|
356 | + $this->logger->error('SCSSCacher: unable to cache: '.$fileNameSCSS); |
|
357 | 357 | |
358 | 358 | return false; |
359 | 359 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | try { |
380 | 380 | $file->delete(); |
381 | 381 | } catch (NotPermittedException $e) { |
382 | - $this->logger->logException($e, ['message' => 'SCSSCacher: unable to delete file: ' . $file->getName()]); |
|
382 | + $this->logger->logException($e, ['message' => 'SCSSCacher: unable to delete file: '.$file->getName()]); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | $variables = ''; |
398 | 398 | foreach ($this->defaults->getScssVariables() as $key => $value) { |
399 | - $variables .= '$' . $key . ': ' . $value . ' !default;'; |
|
399 | + $variables .= '$'.$key.': '.$value.' !default;'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | // check for valid variables / otherwise fall back to defaults |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | private function rebaseUrls(string $css, string $webDir): string { |
421 | 421 | $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; |
422 | - $subst = 'url(\'' . $webDir . '/$1\')'; |
|
422 | + $subst = 'url(\''.$webDir.'/$1\')'; |
|
423 | 423 | |
424 | 424 | return preg_replace($re, $subst, $css); |
425 | 425 | } |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | * @return string |
449 | 449 | */ |
450 | 450 | private function prependBaseurlPrefix(string $cssFile): string { |
451 | - return substr(md5($this->urlGenerator->getBaseUrl() . $this->getRoutePrefix()), 0, 4) . '-' . $cssFile; |
|
451 | + return substr(md5($this->urlGenerator->getBaseUrl().$this->getRoutePrefix()), 0, 4).'-'.$cssFile; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | private function getRoutePrefix() { |
455 | 455 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
456 | - $prefix = \OC::$WEBROOT . '/index.php'; |
|
456 | + $prefix = \OC::$WEBROOT.'/index.php'; |
|
457 | 457 | if ($frontControllerActive) { |
458 | 458 | $prefix = \OC::$WEBROOT; |
459 | 459 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | private function prependVersionPrefix(string $cssFile, string $appId): string { |
470 | 470 | $appVersion = \OC_App::getAppVersion($appId); |
471 | 471 | if ($appVersion !== '0') { |
472 | - return substr(md5($appVersion), 0, 4) . '-' . $cssFile; |
|
472 | + return substr(md5($appVersion), 0, 4).'-'.$cssFile; |
|
473 | 473 | } |
474 | 474 | $coreVersion = \OC_Util::getVersionString(); |
475 | 475 | |
476 | - return substr(md5($coreVersion), 0, 4) . '-' . $cssFile; |
|
476 | + return substr(md5($coreVersion), 0, 4).'-'.$cssFile; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | $appDirectoryPath = explode($appName, $path)[1]; |
492 | 492 | // Remove the webroot |
493 | 493 | |
494 | - return str_replace($webRoot, '', $appWebPath . $appDirectoryPath); |
|
494 | + return str_replace($webRoot, '', $appWebPath.$appDirectoryPath); |
|
495 | 495 | } |
496 | 496 | |
497 | - return $webRoot . substr($path, strlen($serverRoot)); |
|
497 | + return $webRoot.substr($path, strlen($serverRoot)); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |