@@ -85,7 +85,7 @@ |
||
85 | 85 | */ |
86 | 86 | private function generateRandomKey(): string |
87 | 87 | { |
88 | - return bin2hex(random_bytes((int)$this->getOption('length'))); |
|
88 | + return bin2hex(random_bytes((int) $this->getOption('length'))); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $lines = file($filename, FILE_IGNORE_NEW_LINES); |
211 | 211 | |
212 | - if(!$lines) { |
|
212 | + if (!$lines) { |
|
213 | 213 | return []; |
214 | 214 | } |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function fileName(string $path): string |
229 | 229 | { |
230 | - return (string)pathinfo($path, PATHINFO_FILENAME); |
|
230 | + return (string) pathinfo($path, PATHINFO_FILENAME); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function extension(string $path): string |
239 | 239 | { |
240 | - return (string)pathinfo($path, PATHINFO_EXTENSION); |
|
240 | + return (string) pathinfo($path, PATHINFO_EXTENSION); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -163,7 +163,7 @@ |
||
163 | 163 | 'Content-Type' => $contentType |
164 | 164 | ]; |
165 | 165 | return $this->sendRequest($url, $params, $headers, $method); |
166 | - }catch (Exception $e){ |
|
166 | + } catch (Exception $e){ |
|
167 | 167 | throw new Exception($e->getMessage(), (int)$e->getCode()); |
168 | 168 | } |
169 | 169 | } |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | 'Content-Type' => $contentType |
218 | 218 | ]; |
219 | 219 | return $this->sendRequest($url, $params, $headers, $method); |
220 | - }catch (Exception $e){ |
|
221 | - throw new Exception($e->getMessage(), (int)$e->getCode()); |
|
220 | + } catch (Exception $e) { |
|
221 | + throw new Exception($e->getMessage(), (int) $e->getCode()); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @return mixed|null |
231 | 231 | * @throws Exception |
232 | 232 | */ |
233 | - public function getFileInfo(string $fileId, bool $media = false, array $params = []){ |
|
233 | + public function getFileInfo(string $fileId, bool $media = false, array $params = []) { |
|
234 | 234 | $queryParam = $media ? '?alt=media' : '?fields=*'; |
235 | 235 | return $this->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '/' . $fileId . $queryParam, $params, 'GET'); |
236 | 236 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | try { |
83 | 83 | if($this->isFile($filename)){ |
84 | 84 | return $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_MEDIA_URL . '/' . $filename . '?uploadType=media', $content, 'PATCH', 'application/octet-stream'); |
85 | - }else{ |
|
85 | + } else{ |
|
86 | 86 | $data = [ |
87 | 87 | 'name' => $filename, |
88 | 88 | 'parents' => $parentId ? [$parentId] : ['root'] |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function makeDirectory(string $dirname, ?string $parentId = null): bool |
48 | 48 | { |
49 | - try{ |
|
49 | + try { |
|
50 | 50 | $data = [ |
51 | 51 | 'name' => $dirname, |
52 | 52 | 'mimeType' => GoogleDriveApp::FOLDER_MIMETYPE, |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function get(string $filename) |
75 | 75 | { |
76 | 76 | try { |
77 | - return (string)$this->googleDriveApp->getFileInfo($filename, true); |
|
77 | + return (string) $this->googleDriveApp->getFileInfo($filename, true); |
|
78 | 78 | } catch (Exception $e) { |
79 | 79 | return false; |
80 | 80 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | public function put(string $filename, string $content, ?string $parentId = null) |
87 | 87 | { |
88 | 88 | try { |
89 | - if($this->isFile($filename)){ |
|
89 | + if ($this->isFile($filename)) { |
|
90 | 90 | return $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_MEDIA_URL . '/' . $filename . '?uploadType=media', $content, 'PATCH', 'application/octet-stream'); |
91 | - }else{ |
|
91 | + } else { |
|
92 | 92 | $data = [ |
93 | 93 | 'name' => $filename, |
94 | 94 | 'parents' => $parentId ? [$parentId] : ['root'] |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function size(string $filename) |
162 | 162 | { |
163 | 163 | try { |
164 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
164 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
165 | 165 | return $meta['size']; |
166 | 166 | } catch (Exception $e) { |
167 | 167 | return false; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function lastModified(string $filename) |
175 | 175 | { |
176 | 176 | try { |
177 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
177 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
178 | 178 | return !empty($meta['modifiedTime']) ? strtotime($meta['modifiedTime']) : false; |
179 | 179 | } catch (Exception $e) { |
180 | 180 | return false; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function isFile(string $filename): bool |
203 | 203 | { |
204 | 204 | try { |
205 | - $meta = (array)$this->googleDriveApp->getFileInfo($filename); |
|
205 | + $meta = (array) $this->googleDriveApp->getFileInfo($filename); |
|
206 | 206 | |
207 | 207 | return $meta['kind'] === GoogleDriveApp::DRIVE_FILE_KIND && $meta['mimeType'] != GoogleDriveApp::FOLDER_MIMETYPE; |
208 | 208 | } catch (Exception $e) { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function isDirectory(string $dirname): bool |
217 | 217 | { |
218 | 218 | try { |
219 | - $meta = (array)$this->googleDriveApp->getFileInfo($dirname); |
|
219 | + $meta = (array) $this->googleDriveApp->getFileInfo($dirname); |
|
220 | 220 | |
221 | 221 | return $meta['kind'] === GoogleDriveApp::DRIVE_FILE_KIND && $meta['mimeType'] === GoogleDriveApp::FOLDER_MIMETYPE; |
222 | 222 | } catch (Exception $e) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | 'q' => "'$dirname' in parents and trashed = false", |
235 | 235 | 'fields' => '*' |
236 | 236 | ]; |
237 | - $response = (array)$this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '?' . http_build_query($params), [], 'GET'); |
|
237 | + $response = (array) $this->googleDriveApp->rpcRequest(GoogleDriveApp::FILE_METADATA_URL . '?' . http_build_query($params), [], 'GET'); |
|
238 | 238 | return $response["files"]; |
239 | 239 | } catch (Exception $e) { |
240 | 240 | return false; |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $this->importConfig(); |
100 | 100 | $this->initModule($this->getOption('module')); |
101 | 101 | $this->initType($this->getOption('type')); |
102 | - }catch (Exception $e){ |
|
102 | + } catch (Exception $e){ |
|
103 | 103 | $this->error($e->getMessage()); |
104 | 104 | return; |
105 | 105 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->importConfig(); |
100 | 100 | $this->initModule($this->getOption('module')); |
101 | 101 | $this->initType($this->getOption('type')); |
102 | - }catch (Exception $e){ |
|
102 | + } catch (Exception $e) { |
|
103 | 103 | $this->error($e->getMessage()); |
104 | 104 | return; |
105 | 105 | } |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | config()->import(new Setup('config', 'modules')); |
134 | 134 | } |
135 | 135 | |
136 | - if (config()->has('modules') && is_array(config()->get('modules.modules'))){ |
|
136 | + if (config()->has('modules') && is_array(config()->get('modules.modules'))) { |
|
137 | 137 | $this->modules = array_keys(array_change_key_case(config()->get('modules.modules'))); |
138 | 138 | } |
139 | - } catch (ConfigException|DiException|ReflectionException $e) { |
|
139 | + } catch (ConfigException | DiException | ReflectionException $e) { |
|
140 | 140 | $this->error($e->getMessage()); |
141 | 141 | return; |
142 | 142 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (in_array($module, $this->modules)) { |
172 | 172 | $this->module = $module; |
173 | 173 | } else { |
174 | - throw new Exception('Module {'. $module .'} does not exist.'); |
|
174 | + throw new Exception('Module {' . $module . '} does not exist.'); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if (in_array($type, $this->types)) { |
190 | 190 | $this->type = $type; |
191 | 191 | } else { |
192 | - throw new Exception('Cache type {'. $type .'} is invalid.'); |
|
192 | + throw new Exception('Cache type {' . $type . '} is invalid.'); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -30,212 +30,212 @@ |
||
30 | 30 | class ResourceCacheClearCommand extends QtCommand |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * Command name |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $name = 'cache:clear'; |
|
38 | - |
|
39 | - /** |
|
40 | - * Command description |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $description = 'Clears resource cache'; |
|
44 | - |
|
45 | - /** |
|
46 | - * Command help text |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - protected $help = 'The command will clear the resource cache'; |
|
50 | - |
|
51 | - /** |
|
52 | - * Command options |
|
53 | - * @var array |
|
54 | - */ |
|
55 | - protected $options = [ |
|
56 | - ['all', 'all', 'none', ''], |
|
57 | - ['type', 't', 'required', ''], |
|
58 | - ['module', 'm', 'required', ''] |
|
59 | - ]; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var array |
|
63 | - */ |
|
64 | - protected $types = ['views', 'asserts']; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var array |
|
68 | - */ |
|
69 | - protected $modules; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var string|null |
|
73 | - */ |
|
74 | - protected $type = null; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var string|null |
|
78 | - */ |
|
79 | - protected $module = null; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - protected $cacheDir; |
|
85 | - |
|
86 | - /** |
|
87 | - * @var object |
|
88 | - */ |
|
89 | - protected $fs; |
|
33 | + /** |
|
34 | + * Command name |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $name = 'cache:clear'; |
|
38 | + |
|
39 | + /** |
|
40 | + * Command description |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $description = 'Clears resource cache'; |
|
44 | + |
|
45 | + /** |
|
46 | + * Command help text |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + protected $help = 'The command will clear the resource cache'; |
|
50 | + |
|
51 | + /** |
|
52 | + * Command options |
|
53 | + * @var array |
|
54 | + */ |
|
55 | + protected $options = [ |
|
56 | + ['all', 'all', 'none', ''], |
|
57 | + ['type', 't', 'required', ''], |
|
58 | + ['module', 'm', 'required', ''] |
|
59 | + ]; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var array |
|
63 | + */ |
|
64 | + protected $types = ['views', 'asserts']; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var array |
|
68 | + */ |
|
69 | + protected $modules; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var string|null |
|
73 | + */ |
|
74 | + protected $type = null; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var string|null |
|
78 | + */ |
|
79 | + protected $module = null; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + protected $cacheDir; |
|
85 | + |
|
86 | + /** |
|
87 | + * @var object |
|
88 | + */ |
|
89 | + protected $fs; |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @throws BaseException |
93 | 93 | */ |
94 | - public function exec() |
|
95 | - { |
|
96 | - try { |
|
97 | - $this->importConfig(); |
|
98 | - $this->initModule($this->getOption('module')); |
|
99 | - $this->initType($this->getOption('type')); |
|
100 | - }catch (Exception $e){ |
|
101 | - $this->error($e->getMessage()); |
|
102 | - return; |
|
103 | - } |
|
104 | - |
|
105 | - $this->fs = FileSystemFactory::get(); |
|
106 | - |
|
107 | - if (!$this->fs->isDirectory($this->cacheDir)) { |
|
108 | - $this->error('Cache directory does not exist or is not accessible.'); |
|
109 | - return; |
|
110 | - } |
|
111 | - |
|
112 | - if ($this->module || $this->type) { |
|
113 | - $this->clearResourceModuleAndType($this->module, $this->type); |
|
114 | - } elseif (!empty($this->getOption('all'))) { |
|
115 | - $this->removeFilesFromDirectory($this->cacheDir); |
|
116 | - } else { |
|
117 | - $this->error('Please specify at least one of the following options: --all, --module=moduleName or --type=typeName!'); |
|
118 | - return; |
|
119 | - } |
|
120 | - |
|
121 | - $this->info('Resource cache cleared successfully.'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - private function importModules() |
|
128 | - { |
|
129 | - try { |
|
130 | - if (!config()->has('modules')) { |
|
131 | - config()->import(new Setup('config', 'modules')); |
|
132 | - } |
|
133 | - |
|
134 | - if (config()->has('modules') && is_array(config()->get('modules.modules'))){ |
|
135 | - $this->modules = array_keys(array_change_key_case(config()->get('modules.modules'))); |
|
136 | - } |
|
137 | - } catch (ConfigException|DiException|ReflectionException $e) { |
|
138 | - $this->error($e->getMessage()); |
|
139 | - return; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @return void |
|
145 | - * @throws ConfigException |
|
146 | - * @throws DiException |
|
147 | - * @throws ReflectionException |
|
148 | - */ |
|
149 | - private function importConfig(): void |
|
150 | - { |
|
151 | - if (!config()->has('view_cache')) { |
|
152 | - config()->import(new Setup('config', 'view_cache')); |
|
153 | - } |
|
154 | - |
|
155 | - $this->cacheDir = base_dir() . DS . config()->get('view_cache.cache_dir', 'cache'); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param string|null $moduleOption |
|
160 | - * @return void |
|
161 | - * @throws Exception |
|
162 | - */ |
|
163 | - private function initModule(?string $moduleOption): void |
|
164 | - { |
|
165 | - if (!empty($moduleOption)) { |
|
166 | - $this->importModules(); |
|
167 | - $module = strtolower($moduleOption); |
|
168 | - |
|
169 | - if (in_array($module, $this->modules)) { |
|
170 | - $this->module = $module; |
|
171 | - } else { |
|
172 | - throw new Exception('Module {'. $module .'} does not exist.'); |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string|null $typeOption |
|
179 | - * @return void |
|
180 | - * @throws Exception |
|
181 | - */ |
|
182 | - private function initType(?string $typeOption): void |
|
183 | - { |
|
184 | - if (!empty($typeOption)) { |
|
185 | - $type = strtolower($typeOption); |
|
186 | - |
|
187 | - if (in_array($type, $this->types)) { |
|
188 | - $this->type = $type; |
|
189 | - } else { |
|
190 | - throw new Exception('Cache type {'. $type .'} is invalid.'); |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * @param string|null $moduleName |
|
197 | - * @param string|null $type |
|
198 | - * @return void |
|
199 | - */ |
|
200 | - private function clearResourceModuleAndType(?string $moduleName = null, ?string $type = null): void |
|
201 | - { |
|
202 | - $dir = $this->cacheDir; |
|
203 | - |
|
204 | - if ($type) { |
|
205 | - $dir = $dir . DS . strtolower($type); |
|
206 | - } |
|
207 | - |
|
208 | - if ($moduleName) { |
|
209 | - if (!$type) { |
|
210 | - $dir = $dir . DS . '*'; |
|
211 | - } |
|
212 | - |
|
213 | - $dir = $dir . DS . strtolower($moduleName); |
|
214 | - } |
|
215 | - |
|
216 | - $this->removeFilesFromDirectory($dir); |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * @param string $dir |
|
221 | - * @return void |
|
222 | - */ |
|
223 | - private function removeFilesFromDirectory(string $dir): void |
|
224 | - { |
|
225 | - $entries = $this->fs->glob($dir . DS . '*'); |
|
226 | - |
|
227 | - foreach ($entries as $entry) { |
|
228 | - if ($this->fs->isDirectory($entry)) { |
|
229 | - $this->removeFilesFromDirectory($entry); |
|
230 | - |
|
231 | - if ($this->fs->fileName($entry) !== config()->get('view_cache.cache_dir', 'cache') && |
|
232 | - count($this->fs->glob($entry . DS . '*')) === 0 |
|
233 | - ) { |
|
234 | - $this->fs->removeDirectory($entry); |
|
235 | - } |
|
236 | - } else { |
|
237 | - $this->fs->remove($entry); |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
94 | + public function exec() |
|
95 | + { |
|
96 | + try { |
|
97 | + $this->importConfig(); |
|
98 | + $this->initModule($this->getOption('module')); |
|
99 | + $this->initType($this->getOption('type')); |
|
100 | + }catch (Exception $e){ |
|
101 | + $this->error($e->getMessage()); |
|
102 | + return; |
|
103 | + } |
|
104 | + |
|
105 | + $this->fs = FileSystemFactory::get(); |
|
106 | + |
|
107 | + if (!$this->fs->isDirectory($this->cacheDir)) { |
|
108 | + $this->error('Cache directory does not exist or is not accessible.'); |
|
109 | + return; |
|
110 | + } |
|
111 | + |
|
112 | + if ($this->module || $this->type) { |
|
113 | + $this->clearResourceModuleAndType($this->module, $this->type); |
|
114 | + } elseif (!empty($this->getOption('all'))) { |
|
115 | + $this->removeFilesFromDirectory($this->cacheDir); |
|
116 | + } else { |
|
117 | + $this->error('Please specify at least one of the following options: --all, --module=moduleName or --type=typeName!'); |
|
118 | + return; |
|
119 | + } |
|
120 | + |
|
121 | + $this->info('Resource cache cleared successfully.'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + private function importModules() |
|
128 | + { |
|
129 | + try { |
|
130 | + if (!config()->has('modules')) { |
|
131 | + config()->import(new Setup('config', 'modules')); |
|
132 | + } |
|
133 | + |
|
134 | + if (config()->has('modules') && is_array(config()->get('modules.modules'))){ |
|
135 | + $this->modules = array_keys(array_change_key_case(config()->get('modules.modules'))); |
|
136 | + } |
|
137 | + } catch (ConfigException|DiException|ReflectionException $e) { |
|
138 | + $this->error($e->getMessage()); |
|
139 | + return; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @return void |
|
145 | + * @throws ConfigException |
|
146 | + * @throws DiException |
|
147 | + * @throws ReflectionException |
|
148 | + */ |
|
149 | + private function importConfig(): void |
|
150 | + { |
|
151 | + if (!config()->has('view_cache')) { |
|
152 | + config()->import(new Setup('config', 'view_cache')); |
|
153 | + } |
|
154 | + |
|
155 | + $this->cacheDir = base_dir() . DS . config()->get('view_cache.cache_dir', 'cache'); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param string|null $moduleOption |
|
160 | + * @return void |
|
161 | + * @throws Exception |
|
162 | + */ |
|
163 | + private function initModule(?string $moduleOption): void |
|
164 | + { |
|
165 | + if (!empty($moduleOption)) { |
|
166 | + $this->importModules(); |
|
167 | + $module = strtolower($moduleOption); |
|
168 | + |
|
169 | + if (in_array($module, $this->modules)) { |
|
170 | + $this->module = $module; |
|
171 | + } else { |
|
172 | + throw new Exception('Module {'. $module .'} does not exist.'); |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string|null $typeOption |
|
179 | + * @return void |
|
180 | + * @throws Exception |
|
181 | + */ |
|
182 | + private function initType(?string $typeOption): void |
|
183 | + { |
|
184 | + if (!empty($typeOption)) { |
|
185 | + $type = strtolower($typeOption); |
|
186 | + |
|
187 | + if (in_array($type, $this->types)) { |
|
188 | + $this->type = $type; |
|
189 | + } else { |
|
190 | + throw new Exception('Cache type {'. $type .'} is invalid.'); |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * @param string|null $moduleName |
|
197 | + * @param string|null $type |
|
198 | + * @return void |
|
199 | + */ |
|
200 | + private function clearResourceModuleAndType(?string $moduleName = null, ?string $type = null): void |
|
201 | + { |
|
202 | + $dir = $this->cacheDir; |
|
203 | + |
|
204 | + if ($type) { |
|
205 | + $dir = $dir . DS . strtolower($type); |
|
206 | + } |
|
207 | + |
|
208 | + if ($moduleName) { |
|
209 | + if (!$type) { |
|
210 | + $dir = $dir . DS . '*'; |
|
211 | + } |
|
212 | + |
|
213 | + $dir = $dir . DS . strtolower($moduleName); |
|
214 | + } |
|
215 | + |
|
216 | + $this->removeFilesFromDirectory($dir); |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * @param string $dir |
|
221 | + * @return void |
|
222 | + */ |
|
223 | + private function removeFilesFromDirectory(string $dir): void |
|
224 | + { |
|
225 | + $entries = $this->fs->glob($dir . DS . '*'); |
|
226 | + |
|
227 | + foreach ($entries as $entry) { |
|
228 | + if ($this->fs->isDirectory($entry)) { |
|
229 | + $this->removeFilesFromDirectory($entry); |
|
230 | + |
|
231 | + if ($this->fs->fileName($entry) !== config()->get('view_cache.cache_dir', 'cache') && |
|
232 | + count($this->fs->glob($entry . DS . '*')) === 0 |
|
233 | + ) { |
|
234 | + $this->fs->removeDirectory($entry); |
|
235 | + } |
|
236 | + } else { |
|
237 | + $this->fs->remove($entry); |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | 241 | } |
242 | 242 | \ No newline at end of file |
@@ -130,7 +130,7 @@ |
||
130 | 130 | */ |
131 | 131 | function route_cache_settings(): ?array |
132 | 132 | { |
133 | - return RouteController::getCurrentRoute()['cache_settings'] ?? null; |
|
133 | + return RouteController::getCurrentRoute()['cache_settings'] ?? null; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -182,7 +182,7 @@ |
||
182 | 182 | return []; |
183 | 183 | } |
184 | 184 | |
185 | - return (array)require_once $userDependencies; |
|
185 | + return (array) require_once $userDependencies; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -45,7 +45,7 @@ |
||
45 | 45 | return []; |
46 | 46 | } |
47 | 47 | |
48 | - return array_reduce(array_keys($data), function ($headers, $key) use ($data) { |
|
48 | + return array_reduce(array_keys($data), function($headers, $key) use ($data) { |
|
49 | 49 | if (strpos($key, 'HTTP_') === 0) { |
50 | 50 | $formattedKey = strtolower(str_replace('_', '-', substr($key, 5))); |
51 | 51 | $headers[$formattedKey] = $data[$key]; |
@@ -98,7 +98,7 @@ |
||
98 | 98 | ]; |
99 | 99 | |
100 | 100 | if (isset($this->moduleOptions['cacheable'])) { |
101 | - $this->currentRoute['cache_settings']['shouldCache'] = (bool)$this->moduleOptions['cacheable']; |
|
101 | + $this->currentRoute['cache_settings']['shouldCache'] = (bool) $this->moduleOptions['cacheable']; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if (is_callable($params[0])) { |