@@ -35,220 +35,220 @@ |
||
| 35 | 35 | |
| 36 | 36 | class JSCombiner { |
| 37 | 37 | |
| 38 | - /** @var IAppData */ |
|
| 39 | - protected $appData; |
|
| 40 | - |
|
| 41 | - /** @var IURLGenerator */ |
|
| 42 | - protected $urlGenerator; |
|
| 43 | - |
|
| 44 | - /** @var ICache */ |
|
| 45 | - protected $depsCache; |
|
| 46 | - |
|
| 47 | - /** @var SystemConfig */ |
|
| 48 | - protected $config; |
|
| 49 | - |
|
| 50 | - /** @var ILogger */ |
|
| 51 | - protected $logger; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param IAppData $appData |
|
| 55 | - * @param IURLGenerator $urlGenerator |
|
| 56 | - * @param ICache $depsCache |
|
| 57 | - * @param SystemConfig $config |
|
| 58 | - * @param ILogger $logger |
|
| 59 | - */ |
|
| 60 | - public function __construct(IAppData $appData, |
|
| 61 | - IURLGenerator $urlGenerator, |
|
| 62 | - ICache $depsCache, |
|
| 63 | - SystemConfig $config, |
|
| 64 | - ILogger $logger) { |
|
| 65 | - $this->appData = $appData; |
|
| 66 | - $this->urlGenerator = $urlGenerator; |
|
| 67 | - $this->depsCache = $depsCache; |
|
| 68 | - $this->config = $config; |
|
| 69 | - $this->logger = $logger; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @param string $root |
|
| 74 | - * @param string $file |
|
| 75 | - * @param string $app |
|
| 76 | - * @return bool |
|
| 77 | - */ |
|
| 78 | - public function process($root, $file, $app) { |
|
| 79 | - if ($this->config->getValue('debug') || !$this->config->getValue('installed')) { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $path = explode('/', $root . '/' . $file); |
|
| 84 | - |
|
| 85 | - $fileName = array_pop($path); |
|
| 86 | - $path = implode('/', $path); |
|
| 87 | - |
|
| 88 | - try { |
|
| 89 | - $folder = $this->appData->getFolder($app); |
|
| 90 | - } catch(NotFoundException $e) { |
|
| 91 | - // creating css appdata folder |
|
| 92 | - $folder = $this->appData->newFolder($app); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if($this->isCached($fileName, $folder)) { |
|
| 96 | - return true; |
|
| 97 | - } |
|
| 98 | - return $this->cache($path, $fileName, $folder); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @param string $fileName |
|
| 103 | - * @param ISimpleFolder $folder |
|
| 104 | - * @return bool |
|
| 105 | - */ |
|
| 106 | - protected function isCached($fileName, ISimpleFolder $folder) { |
|
| 107 | - $fileName = str_replace('.json', '.js', $fileName); |
|
| 108 | - |
|
| 109 | - if (!$folder->fileExists($fileName)) { |
|
| 110 | - return false; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $fileName = $fileName . '.deps'; |
|
| 114 | - try { |
|
| 115 | - $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
| 116 | - if ($deps === null || $deps === '') { |
|
| 117 | - $depFile = $folder->getFile($fileName); |
|
| 118 | - $deps = $depFile->getContent(); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // check again |
|
| 122 | - if ($deps === null || $deps === '') { |
|
| 123 | - $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
| 124 | - return false; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $deps = json_decode($deps, true); |
|
| 128 | - |
|
| 129 | - if ($deps === NULL) { |
|
| 130 | - return false; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - foreach ($deps as $file=>$mtime) { |
|
| 134 | - if (!file_exists($file) || filemtime($file) > $mtime) { |
|
| 135 | - return false; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return true; |
|
| 140 | - } catch(NotFoundException $e) { |
|
| 141 | - return false; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @param string $path |
|
| 147 | - * @param string $fileName |
|
| 148 | - * @param ISimpleFolder $folder |
|
| 149 | - * @return bool |
|
| 150 | - */ |
|
| 151 | - protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
| 152 | - $deps = []; |
|
| 153 | - $fullPath = $path . '/' . $fileName; |
|
| 154 | - $data = json_decode(file_get_contents($fullPath)); |
|
| 155 | - $deps[$fullPath] = filemtime($fullPath); |
|
| 156 | - |
|
| 157 | - $res = ''; |
|
| 158 | - foreach ($data as $file) { |
|
| 159 | - $filePath = $path . '/' . $file; |
|
| 160 | - |
|
| 161 | - if (is_file($filePath)) { |
|
| 162 | - $res .= file_get_contents($filePath); |
|
| 163 | - $res .= PHP_EOL . PHP_EOL; |
|
| 164 | - $deps[$filePath] = filemtime($filePath); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $fileName = str_replace('.json', '.js', $fileName); |
|
| 169 | - try { |
|
| 170 | - $cachedfile = $folder->getFile($fileName); |
|
| 171 | - } catch(NotFoundException $e) { |
|
| 172 | - $cachedfile = $folder->newFile($fileName); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $depFileName = $fileName . '.deps'; |
|
| 176 | - try { |
|
| 177 | - $depFile = $folder->getFile($depFileName); |
|
| 178 | - } catch (NotFoundException $e) { |
|
| 179 | - $depFile = $folder->newFile($depFileName); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - try { |
|
| 183 | - $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 184 | - } catch (NotFoundException $e) { |
|
| 185 | - $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - try { |
|
| 189 | - $cachedfile->putContent($res); |
|
| 190 | - $deps = json_encode($deps); |
|
| 191 | - $depFile->putContent($deps); |
|
| 192 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
| 193 | - $gzipFile->putContent(gzencode($res, 9)); |
|
| 194 | - $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
| 195 | - return true; |
|
| 196 | - } catch (NotPermittedException $e) { |
|
| 197 | - $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @param string $appName |
|
| 204 | - * @param string $fileName |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 207 | - public function getCachedJS($appName, $fileName) { |
|
| 208 | - $tmpfileLoc = explode('/', $fileName); |
|
| 209 | - $fileName = array_pop($tmpfileLoc); |
|
| 210 | - $fileName = str_replace('.json', '.js', $fileName); |
|
| 211 | - |
|
| 212 | - return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @param string $root |
|
| 217 | - * @param string $file |
|
| 218 | - * @return string[] |
|
| 219 | - */ |
|
| 220 | - public function getContent($root, $file) { |
|
| 221 | - /** @var array $data */ |
|
| 222 | - $data = json_decode(file_get_contents($root . '/' . $file)); |
|
| 223 | - if(!is_array($data)) { |
|
| 224 | - return []; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $path = explode('/', $file); |
|
| 228 | - array_pop($path); |
|
| 229 | - $path = implode('/', $path); |
|
| 230 | - |
|
| 231 | - $result = []; |
|
| 232 | - foreach ($data as $f) { |
|
| 233 | - $result[] = $path . '/' . $f; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return $result; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Clear cache with combined javascript files |
|
| 242 | - * |
|
| 243 | - * @throws NotFoundException |
|
| 244 | - */ |
|
| 245 | - public function resetCache() { |
|
| 246 | - $this->depsCache->clear(); |
|
| 247 | - $appDirectory = $this->appData->getDirectoryListing(); |
|
| 248 | - foreach ($appDirectory as $folder) { |
|
| 249 | - foreach ($folder->getDirectoryListing() as $file) { |
|
| 250 | - $file->delete(); |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 38 | + /** @var IAppData */ |
|
| 39 | + protected $appData; |
|
| 40 | + |
|
| 41 | + /** @var IURLGenerator */ |
|
| 42 | + protected $urlGenerator; |
|
| 43 | + |
|
| 44 | + /** @var ICache */ |
|
| 45 | + protected $depsCache; |
|
| 46 | + |
|
| 47 | + /** @var SystemConfig */ |
|
| 48 | + protected $config; |
|
| 49 | + |
|
| 50 | + /** @var ILogger */ |
|
| 51 | + protected $logger; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param IAppData $appData |
|
| 55 | + * @param IURLGenerator $urlGenerator |
|
| 56 | + * @param ICache $depsCache |
|
| 57 | + * @param SystemConfig $config |
|
| 58 | + * @param ILogger $logger |
|
| 59 | + */ |
|
| 60 | + public function __construct(IAppData $appData, |
|
| 61 | + IURLGenerator $urlGenerator, |
|
| 62 | + ICache $depsCache, |
|
| 63 | + SystemConfig $config, |
|
| 64 | + ILogger $logger) { |
|
| 65 | + $this->appData = $appData; |
|
| 66 | + $this->urlGenerator = $urlGenerator; |
|
| 67 | + $this->depsCache = $depsCache; |
|
| 68 | + $this->config = $config; |
|
| 69 | + $this->logger = $logger; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param string $root |
|
| 74 | + * @param string $file |
|
| 75 | + * @param string $app |
|
| 76 | + * @return bool |
|
| 77 | + */ |
|
| 78 | + public function process($root, $file, $app) { |
|
| 79 | + if ($this->config->getValue('debug') || !$this->config->getValue('installed')) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $path = explode('/', $root . '/' . $file); |
|
| 84 | + |
|
| 85 | + $fileName = array_pop($path); |
|
| 86 | + $path = implode('/', $path); |
|
| 87 | + |
|
| 88 | + try { |
|
| 89 | + $folder = $this->appData->getFolder($app); |
|
| 90 | + } catch(NotFoundException $e) { |
|
| 91 | + // creating css appdata folder |
|
| 92 | + $folder = $this->appData->newFolder($app); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if($this->isCached($fileName, $folder)) { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | + return $this->cache($path, $fileName, $folder); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @param string $fileName |
|
| 103 | + * @param ISimpleFolder $folder |
|
| 104 | + * @return bool |
|
| 105 | + */ |
|
| 106 | + protected function isCached($fileName, ISimpleFolder $folder) { |
|
| 107 | + $fileName = str_replace('.json', '.js', $fileName); |
|
| 108 | + |
|
| 109 | + if (!$folder->fileExists($fileName)) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $fileName = $fileName . '.deps'; |
|
| 114 | + try { |
|
| 115 | + $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
| 116 | + if ($deps === null || $deps === '') { |
|
| 117 | + $depFile = $folder->getFile($fileName); |
|
| 118 | + $deps = $depFile->getContent(); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // check again |
|
| 122 | + if ($deps === null || $deps === '') { |
|
| 123 | + $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
| 124 | + return false; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $deps = json_decode($deps, true); |
|
| 128 | + |
|
| 129 | + if ($deps === NULL) { |
|
| 130 | + return false; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + foreach ($deps as $file=>$mtime) { |
|
| 134 | + if (!file_exists($file) || filemtime($file) > $mtime) { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return true; |
|
| 140 | + } catch(NotFoundException $e) { |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @param string $path |
|
| 147 | + * @param string $fileName |
|
| 148 | + * @param ISimpleFolder $folder |
|
| 149 | + * @return bool |
|
| 150 | + */ |
|
| 151 | + protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
| 152 | + $deps = []; |
|
| 153 | + $fullPath = $path . '/' . $fileName; |
|
| 154 | + $data = json_decode(file_get_contents($fullPath)); |
|
| 155 | + $deps[$fullPath] = filemtime($fullPath); |
|
| 156 | + |
|
| 157 | + $res = ''; |
|
| 158 | + foreach ($data as $file) { |
|
| 159 | + $filePath = $path . '/' . $file; |
|
| 160 | + |
|
| 161 | + if (is_file($filePath)) { |
|
| 162 | + $res .= file_get_contents($filePath); |
|
| 163 | + $res .= PHP_EOL . PHP_EOL; |
|
| 164 | + $deps[$filePath] = filemtime($filePath); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $fileName = str_replace('.json', '.js', $fileName); |
|
| 169 | + try { |
|
| 170 | + $cachedfile = $folder->getFile($fileName); |
|
| 171 | + } catch(NotFoundException $e) { |
|
| 172 | + $cachedfile = $folder->newFile($fileName); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $depFileName = $fileName . '.deps'; |
|
| 176 | + try { |
|
| 177 | + $depFile = $folder->getFile($depFileName); |
|
| 178 | + } catch (NotFoundException $e) { |
|
| 179 | + $depFile = $folder->newFile($depFileName); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + try { |
|
| 183 | + $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 184 | + } catch (NotFoundException $e) { |
|
| 185 | + $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + try { |
|
| 189 | + $cachedfile->putContent($res); |
|
| 190 | + $deps = json_encode($deps); |
|
| 191 | + $depFile->putContent($deps); |
|
| 192 | + $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
| 193 | + $gzipFile->putContent(gzencode($res, 9)); |
|
| 194 | + $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
| 195 | + return true; |
|
| 196 | + } catch (NotPermittedException $e) { |
|
| 197 | + $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @param string $appName |
|
| 204 | + * @param string $fileName |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | + public function getCachedJS($appName, $fileName) { |
|
| 208 | + $tmpfileLoc = explode('/', $fileName); |
|
| 209 | + $fileName = array_pop($tmpfileLoc); |
|
| 210 | + $fileName = str_replace('.json', '.js', $fileName); |
|
| 211 | + |
|
| 212 | + return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param string $root |
|
| 217 | + * @param string $file |
|
| 218 | + * @return string[] |
|
| 219 | + */ |
|
| 220 | + public function getContent($root, $file) { |
|
| 221 | + /** @var array $data */ |
|
| 222 | + $data = json_decode(file_get_contents($root . '/' . $file)); |
|
| 223 | + if(!is_array($data)) { |
|
| 224 | + return []; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $path = explode('/', $file); |
|
| 228 | + array_pop($path); |
|
| 229 | + $path = implode('/', $path); |
|
| 230 | + |
|
| 231 | + $result = []; |
|
| 232 | + foreach ($data as $f) { |
|
| 233 | + $result[] = $path . '/' . $f; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return $result; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Clear cache with combined javascript files |
|
| 242 | + * |
|
| 243 | + * @throws NotFoundException |
|
| 244 | + */ |
|
| 245 | + public function resetCache() { |
|
| 246 | + $this->depsCache->clear(); |
|
| 247 | + $appDirectory = $this->appData->getDirectoryListing(); |
|
| 248 | + foreach ($appDirectory as $folder) { |
|
| 249 | + foreach ($folder->getDirectoryListing() as $file) { |
|
| 250 | + $file->delete(); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | } |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $path = explode('/', $root . '/' . $file); |
|
| 83 | + $path = explode('/', $root.'/'.$file); |
|
| 84 | 84 | |
| 85 | 85 | $fileName = array_pop($path); |
| 86 | 86 | $path = implode('/', $path); |
| 87 | 87 | |
| 88 | 88 | try { |
| 89 | 89 | $folder = $this->appData->getFolder($app); |
| 90 | - } catch(NotFoundException $e) { |
|
| 90 | + } catch (NotFoundException $e) { |
|
| 91 | 91 | // creating css appdata folder |
| 92 | 92 | $folder = $this->appData->newFolder($app); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($this->isCached($fileName, $folder)) { |
|
| 95 | + if ($this->isCached($fileName, $folder)) { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | return $this->cache($path, $fileName, $folder); |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $fileName = $fileName . '.deps'; |
|
| 113 | + $fileName = $fileName.'.deps'; |
|
| 114 | 114 | try { |
| 115 | - $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
| 115 | + $deps = $this->depsCache->get($folder->getName().'-'.$fileName); |
|
| 116 | 116 | if ($deps === null || $deps === '') { |
| 117 | 117 | $depFile = $folder->getFile($fileName); |
| 118 | 118 | $deps = $depFile->getContent(); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // check again |
| 122 | 122 | if ($deps === null || $deps === '') { |
| 123 | - $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
| 123 | + $this->logger->info('JSCombiner: deps file empty: '.$fileName); |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return true; |
| 140 | - } catch(NotFoundException $e) { |
|
| 140 | + } catch (NotFoundException $e) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | protected function cache($path, $fileName, ISimpleFolder $folder) { |
| 152 | 152 | $deps = []; |
| 153 | - $fullPath = $path . '/' . $fileName; |
|
| 153 | + $fullPath = $path.'/'.$fileName; |
|
| 154 | 154 | $data = json_decode(file_get_contents($fullPath)); |
| 155 | 155 | $deps[$fullPath] = filemtime($fullPath); |
| 156 | 156 | |
| 157 | 157 | $res = ''; |
| 158 | 158 | foreach ($data as $file) { |
| 159 | - $filePath = $path . '/' . $file; |
|
| 159 | + $filePath = $path.'/'.$file; |
|
| 160 | 160 | |
| 161 | 161 | if (is_file($filePath)) { |
| 162 | 162 | $res .= file_get_contents($filePath); |
| 163 | - $res .= PHP_EOL . PHP_EOL; |
|
| 163 | + $res .= PHP_EOL.PHP_EOL; |
|
| 164 | 164 | $deps[$filePath] = filemtime($filePath); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | $fileName = str_replace('.json', '.js', $fileName); |
| 169 | 169 | try { |
| 170 | 170 | $cachedfile = $folder->getFile($fileName); |
| 171 | - } catch(NotFoundException $e) { |
|
| 171 | + } catch (NotFoundException $e) { |
|
| 172 | 172 | $cachedfile = $folder->newFile($fileName); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $depFileName = $fileName . '.deps'; |
|
| 175 | + $depFileName = $fileName.'.deps'; |
|
| 176 | 176 | try { |
| 177 | 177 | $depFile = $folder->getFile($depFileName); |
| 178 | 178 | } catch (NotFoundException $e) { |
@@ -180,21 +180,21 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | try { |
| 183 | - $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 183 | + $gzipFile = $folder->getFile($fileName.'.gzip'); # Safari doesn't like .gz |
|
| 184 | 184 | } catch (NotFoundException $e) { |
| 185 | - $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
| 185 | + $gzipFile = $folder->newFile($fileName.'.gzip'); # Safari doesn't like .gz |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | try { |
| 189 | 189 | $cachedfile->putContent($res); |
| 190 | 190 | $deps = json_encode($deps); |
| 191 | 191 | $depFile->putContent($deps); |
| 192 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
| 192 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
| 193 | 193 | $gzipFile->putContent(gzencode($res, 9)); |
| 194 | - $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
| 194 | + $this->logger->debug('JSCombiner: successfully cached: '.$fileName); |
|
| 195 | 195 | return true; |
| 196 | 196 | } catch (NotPermittedException $e) { |
| 197 | - $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
| 197 | + $this->logger->error('JSCombiner: unable to cache: '.$fileName); |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function getContent($root, $file) { |
| 221 | 221 | /** @var array $data */ |
| 222 | - $data = json_decode(file_get_contents($root . '/' . $file)); |
|
| 223 | - if(!is_array($data)) { |
|
| 222 | + $data = json_decode(file_get_contents($root.'/'.$file)); |
|
| 223 | + if (!is_array($data)) { |
|
| 224 | 224 | return []; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $result = []; |
| 232 | 232 | foreach ($data as $f) { |
| 233 | - $result[] = $path . '/' . $f; |
|
| 233 | + $result[] = $path.'/'.$f; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | return $result; |