@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | foreach ($compiledFiles as $file) { |
| 29 | 29 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 30 | 30 | } |
| 31 | - } else { |
|
| 31 | + }else { |
|
| 32 | 32 | $sri = $this->getJsSRIHash($hash, 'js'); |
| 33 | - echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'" . |
|
| 34 | - " crossorigin='anonymous' integrity='sha384-" . $sri . "'></script>\n"; |
|
| 33 | + echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'". |
|
| 34 | + " crossorigin='anonymous' integrity='sha384-".$sri."'></script>\n"; |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles) |
| 48 | 48 | { |
| 49 | - $filePath = $hash . "_" . $pathParts[count($pathParts) - 1]; |
|
| 50 | - $compiledFiles[] = "/js/" . $filePath; |
|
| 49 | + $filePath = $hash."_".$pathParts[count($pathParts) - 1]; |
|
| 50 | + $compiledFiles[] = "/js/".$filePath; |
|
| 51 | 51 | $data = ""; |
| 52 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) { |
|
| 52 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) { |
|
| 53 | 53 | $data = file_get_contents($file); |
| 54 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
| 54 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
| 55 | 55 | } |
| 56 | 56 | return $data; |
| 57 | 57 | } |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles) |
| 69 | 69 | { |
| 70 | - $base = $basePath . "js" . DIRECTORY_SEPARATOR; |
|
| 70 | + $base = $basePath."js".DIRECTORY_SEPARATOR; |
|
| 71 | 71 | $debug = Config::getParam('debug'); |
| 72 | - if ($debug || !file_exists($base . $hash . ".js")) { |
|
| 72 | + if ($debug || !file_exists($base.$hash.".js")) { |
|
| 73 | 73 | $data = ''; |
| 74 | 74 | if (0 < count($files)) { |
| 75 | 75 | $minifier = new JS(); |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | if (file_exists($file)) { |
| 79 | 79 | if ($debug) { |
| 80 | 80 | $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles); |
| 81 | - } elseif (!file_exists($base . $hash . ".js")) { |
|
| 81 | + } elseif (!file_exists($base.$hash.".js")) { |
|
| 82 | 82 | $minifier->add($file); |
| 83 | 83 | //$data = $this->putProductionJs($base, $file, $data); |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - if($debug) { |
|
| 88 | - AssetsHelper::storeContents($base . $hash . ".js", $data); |
|
| 89 | - } else { |
|
| 87 | + if ($debug) { |
|
| 88 | + AssetsHelper::storeContents($base.$hash.".js", $data); |
|
| 89 | + }else { |
|
| 90 | 90 | $this->dumpJs($hash, $base, $minifier); |
| 91 | 91 | } |
| 92 | 92 | unset($minifier); |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | ini_set('memory_limit', -1); |
| 108 | 108 | GeneratorHelper::createDir($base); |
| 109 | 109 | if (Config::getParam('assets.obfuscate', false)) { |
| 110 | - $minifier->gzip($base . $hash . ".js"); |
|
| 111 | - } else { |
|
| 112 | - $minifier->minify($base . $hash . ".js"); |
|
| 110 | + $minifier->gzip($base.$hash.".js"); |
|
| 111 | + }else { |
|
| 112 | + $minifier->minify($base.$hash.".js"); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | protected function compileCss($basePath, $hash) |
| 35 | 35 | { |
| 36 | 36 | $debug = Config::getParam('debug'); |
| 37 | - $base = $basePath . "css" . DIRECTORY_SEPARATOR; |
|
| 38 | - if ($debug || !file_exists($base . $hash . ".css")) { |
|
| 37 | + $base = $basePath."css".DIRECTORY_SEPARATOR; |
|
| 38 | + if ($debug || !file_exists($base.$hash.".css")) { |
|
| 39 | 39 | $data = ''; |
| 40 | 40 | if (0 < count($this->files)) { |
| 41 | 41 | $minifier = new CSS(); |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | $data = $this->processCssLine($file, $base, $data, $hash); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - if($debug) { |
|
| 47 | - AssetsHelper::storeContents($base . $hash . ".css", $data); |
|
| 48 | - } else { |
|
| 46 | + if ($debug) { |
|
| 47 | + AssetsHelper::storeContents($base.$hash.".css", $data); |
|
| 48 | + }else { |
|
| 49 | 49 | $minifier = new CSS(); |
| 50 | 50 | $minifier->add($data); |
| 51 | 51 | ini_set('max_execution_time', -1); |
| 52 | 52 | ini_set('memory_limit', -1); |
| 53 | 53 | GeneratorHelper::createDir($base); |
| 54 | - $minifier->minify($base . $hash . ".css"); |
|
| 54 | + $minifier->minify($base.$hash.".css"); |
|
| 55 | 55 | } |
| 56 | 56 | unset($minifier); |
| 57 | 57 | } |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | if (file_exists($file)) { |
| 72 | 72 | $debug = Config::getParam('debug'); |
| 73 | 73 | $pathParts = explode("/", $file); |
| 74 | - $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1]; |
|
| 75 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) { |
|
| 74 | + $filePath = $this->hash."_".$pathParts[count($pathParts) - 1]; |
|
| 75 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) { |
|
| 76 | 76 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 77 | - if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) { |
|
| 78 | - throw new ConfigException("Can't unlink file " . $base . $hash . ".css"); |
|
| 77 | + if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) { |
|
| 78 | + throw new ConfigException("Can't unlink file ".$base.$hash.".css"); |
|
| 79 | 79 | } |
| 80 | 80 | $this->loopCssLines($file); |
| 81 | 81 | } |
| 82 | 82 | if ($debug) { |
| 83 | 83 | $data = file_get_contents($file); |
| 84 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
| 85 | - } else { |
|
| 84 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
| 85 | + }else { |
|
| 86 | 86 | $data .= file_get_contents($file); |
| 87 | 87 | } |
| 88 | - $this->compiledFiles[] = "/css/" . $filePath; |
|
| 88 | + $this->compiledFiles[] = "/css/".$filePath; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $data; |
@@ -117,25 +117,25 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function extractCssResources($source, $file) |
| 119 | 119 | { |
| 120 | - Inspector::stats('[CssTrait] Start collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
| 120 | + Inspector::stats('[CssTrait] Start collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
| 121 | 121 | $sourceFile = AssetsHelper::extractSourceFilename($source); |
| 122 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile); |
|
| 122 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile); |
|
| 123 | 123 | $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 124 | 124 | try { |
| 125 | 125 | if (count($source) > 1 && array_key_exists(1, $origPart)) { |
| 126 | - $dest = $this->path . $origPart[1]; |
|
| 126 | + $dest = $this->path.$origPart[1]; |
|
| 127 | 127 | GeneratorHelper::createDir(dirname($dest)); |
| 128 | 128 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 129 | 129 | if (@copy($orig, $dest) === FALSE) { |
| 130 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 130 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 131 | 131 | } |
| 132 | 132 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - } catch (\Exception $e) { |
|
| 135 | + }catch (\Exception $e) { |
|
| 136 | 136 | Logger::log($e->getMessage(), LOG_ERR); |
| 137 | 137 | } |
| 138 | - Inspector::stats('[CssTrait] End collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
| 138 | + Inspector::stats('[CssTrait] End collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | foreach ($compiledFiles as $file) { |
| 150 | 150 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 151 | 151 | } |
| 152 | - } else { |
|
| 152 | + }else { |
|
| 153 | 153 | $sri = $this->getCssSRIHash($hash, 'css'); |
| 154 | - echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet' " . |
|
| 155 | - "crossorigin='anonymous' integrity='sha384-" . $sri . "'>"; |
|
| 154 | + echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet' ". |
|
| 155 | + "crossorigin='anonymous' integrity='sha384-".$sri."'>"; |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |