@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public function onBeforeWrite() { |
124 | - if(!$this->AuthorID) { |
|
124 | + if (!$this->AuthorID) { |
|
125 | 125 | $this->AuthorID = Member::currentUserID(); |
126 | 126 | } |
127 | 127 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @return string The human-readable size of this archive file |
180 | 180 | */ |
181 | 181 | public function FileSize() { |
182 | - if($this->ArchiveFile()->exists()) { |
|
182 | + if ($this->ArchiveFile()->exists()) { |
|
183 | 183 | return $this->ArchiveFile()->getSize(); |
184 | 184 | } else { |
185 | 185 | return "N/A"; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | public function getModeNice() { |
190 | - if($this->Mode == 'all') { |
|
190 | + if ($this->Mode == 'all') { |
|
191 | 191 | return 'database and assets'; |
192 | 192 | } else { |
193 | 193 | return $this->Mode; |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function canRestore($member = null) { |
225 | 225 | $memberID = $member ? $member->ID : Member::currentUserID(); |
226 | - if(!$memberID) { |
|
226 | + if (!$memberID) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | - $key = $memberID . '-' . $this->EnvironmentID; |
|
231 | - if(!isset(self::$_cache_can_restore[$key])) { |
|
230 | + $key = $memberID.'-'.$this->EnvironmentID; |
|
231 | + if (!isset(self::$_cache_can_restore[$key])) { |
|
232 | 232 | self::$_cache_can_restore[$key] = $this->Environment()->canUploadArchive($member); |
233 | 233 | } |
234 | 234 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function canDownload($member = null) { |
246 | 246 | $memberID = $member ? $member->ID : Member::currentUserID(); |
247 | - if(!$memberID) { |
|
247 | + if (!$memberID) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | - $key = $memberID . '-' . $this->EnvironmentID; |
|
252 | - if(!isset(self::$_cache_can_download[$key])) { |
|
251 | + $key = $memberID.'-'.$this->EnvironmentID; |
|
252 | + if (!isset(self::$_cache_can_download[$key])) { |
|
253 | 253 | self::$_cache_can_download[$key] = $this->Environment()->canDownloadArchive($member); |
254 | 254 | } |
255 | 255 | return self::$_cache_can_download[$key]; |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | * @return boolean true if $member can upload archives linked to this environment, false if they can't. |
275 | 275 | */ |
276 | 276 | public function canMoveTo($targetEnv, $member = null) { |
277 | - if($this->Environment()->Project()->ID != $targetEnv->Project()->ID) { |
|
277 | + if ($this->Environment()->Project()->ID != $targetEnv->Project()->ID) { |
|
278 | 278 | // We don't permit moving snapshots between projects at this stage. |
279 | 279 | return false; |
280 | 280 | } |
281 | 281 | |
282 | - if(!$member) { |
|
282 | + if (!$member) { |
|
283 | 283 | $member = Member::currentUser(); |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Must be logged in to check permissions |
287 | - if(!$member) { |
|
287 | + if (!$member) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Admin can always move. |
292 | - if(Permission::checkMember($member, 'ADMIN')) { |
|
292 | + if (Permission::checkMember($member, 'ADMIN')) { |
|
293 | 293 | return true; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Checks if the user can actually access the archive. |
297 | - if(!$this->canDownload($member)) { |
|
297 | + if (!$this->canDownload($member)) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return bool |
404 | 404 | */ |
405 | 405 | public function extractArchive($workingDir = null) { |
406 | - if(!is_dir($workingDir)) { |
|
406 | + if (!is_dir($workingDir)) { |
|
407 | 407 | mkdir($workingDir, 0700, true); |
408 | 408 | } |
409 | 409 | |
@@ -422,28 +422,28 @@ discard block |
||
422 | 422 | )); |
423 | 423 | $process->setTimeout(3600); |
424 | 424 | $process->run(); |
425 | - if(!$process->isSuccessful()) { |
|
425 | + if (!$process->isSuccessful()) { |
|
426 | 426 | $cleanupFn(); |
427 | 427 | throw new RuntimeException(sprintf('Could not extract the sspak file: %s', $process->getErrorOutput())); |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Extract database.sql.gz to <workingdir>/database.sql |
431 | - if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) { |
|
431 | + if (file_exists($workingDir.DIRECTORY_SEPARATOR.'database.sql.gz')) { |
|
432 | 432 | $process = new AbortableProcess('gunzip database.sql.gz', $workingDir); |
433 | 433 | $process->setTimeout(3600); |
434 | 434 | $process->run(); |
435 | - if(!$process->isSuccessful()) { |
|
435 | + if (!$process->isSuccessful()) { |
|
436 | 436 | $cleanupFn(); |
437 | 437 | throw new RuntimeException(sprintf('Could not extract the db archive: %s', $process->getErrorOutput())); |
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Extract assets.tar.gz to <workingdir>/assets/ |
442 | - if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) { |
|
442 | + if (file_exists($workingDir.DIRECTORY_SEPARATOR.'assets.tar.gz')) { |
|
443 | 443 | $process = new AbortableProcess('tar xzf assets.tar.gz', $workingDir); |
444 | 444 | $process->setTimeout(3600); |
445 | 445 | $process->run(); |
446 | - if(!$process->isSuccessful()) { |
|
446 | + if (!$process->isSuccessful()) { |
|
447 | 447 | $cleanupFn(); |
448 | 448 | throw new RuntimeException(sprintf('Could not extract the assets archive: %s', $process->getErrorOutput())); |
449 | 449 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | |
468 | 468 | $file = $this->ArchiveFile()->FullPath; |
469 | 469 | |
470 | - if(!is_readable($file)) { |
|
470 | + if (!is_readable($file)) { |
|
471 | 471 | $result->error(sprintf('SSPak file "%s" cannot be read.', $file)); |
472 | 472 | return $result; |
473 | 473 | } |
@@ -475,19 +475,19 @@ discard block |
||
475 | 475 | $process = new AbortableProcess(sprintf('tar -tf %s', escapeshellarg($file))); |
476 | 476 | $process->setTimeout(120); |
477 | 477 | $process->run(); |
478 | - if(!$process->isSuccessful()) { |
|
478 | + if (!$process->isSuccessful()) { |
|
479 | 479 | throw new RuntimeException(sprintf('Could not list files in archive: %s', $process->getErrorOutput())); |
480 | 480 | } |
481 | 481 | |
482 | 482 | $output = explode(PHP_EOL, $process->getOutput()); |
483 | 483 | $files = array_filter($output); |
484 | 484 | |
485 | - if(in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) { |
|
485 | + if (in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) { |
|
486 | 486 | $result->error('The snapshot is missing the database.'); |
487 | 487 | return $result; |
488 | 488 | } |
489 | 489 | |
490 | - if(in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) { |
|
490 | + if (in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) { |
|
491 | 491 | $result->error('The snapshot is missing assets.'); |
492 | 492 | return $result; |
493 | 493 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | sprintf('find %s -type f -exec chmod 644 {} +', escapeshellarg($workingDir)) |
518 | 518 | ); |
519 | 519 | |
520 | - foreach($fixCmds as $cmd) { |
|
520 | + foreach ($fixCmds as $cmd) { |
|
521 | 521 | $process = new AbortableProcess($cmd); |
522 | 522 | $process->setTimeout(3600); |
523 | 523 | $process->run(); |
524 | - if(!$process->isSuccessful()) { |
|
524 | + if (!$process->isSuccessful()) { |
|
525 | 525 | throw new RuntimeException($process->getErrorOutput()); |
526 | 526 | } |
527 | 527 | } |
@@ -540,18 +540,18 @@ discard block |
||
540 | 540 | */ |
541 | 541 | public function setArchiveFromFiles($workingDir) { |
542 | 542 | $commands = array(); |
543 | - if($this->Mode == 'db') { |
|
544 | - if (file_exists($workingDir . '/database.sql')) { |
|
543 | + if ($this->Mode == 'db') { |
|
544 | + if (file_exists($workingDir.'/database.sql')) { |
|
545 | 545 | $commands[] = 'gzip database.sql'; |
546 | 546 | } |
547 | 547 | $commands[] = sprintf('tar -cf %s database.sql.gz', $this->ArchiveFile()->FullPath); |
548 | 548 | $commands[] = 'rm -f database.sql.gz'; |
549 | - } elseif($this->Mode == 'assets') { |
|
549 | + } elseif ($this->Mode == 'assets') { |
|
550 | 550 | $commands[] = 'GZIP=-1 tar --dereference -czf assets.tar.gz assets'; |
551 | 551 | $commands[] = sprintf('tar -cf %s assets.tar.gz', $this->ArchiveFile()->FullPath); |
552 | 552 | $commands[] = 'rm -f assets.tar.gz'; |
553 | 553 | } else { |
554 | - if (file_exists($workingDir . '/database.sql')) { |
|
554 | + if (file_exists($workingDir.'/database.sql')) { |
|
555 | 555 | $commands[] = 'gzip database.sql'; |
556 | 556 | } |
557 | 557 | $commands[] = 'GZIP=-1 tar --dereference -czf assets.tar.gz assets'; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $process = new AbortableProcess(implode(' && ', $commands), $workingDir); |
563 | 563 | $process->setTimeout(3600); |
564 | 564 | $process->run(); |
565 | - if(!$process->isSuccessful()) { |
|
565 | + if (!$process->isSuccessful()) { |
|
566 | 566 | throw new RuntimeException($process->getErrorOutput()); |
567 | 567 | } |
568 | 568 |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | public function run($request) { |
6 | 6 | $log = function($message) { |
7 | - $message = sprintf('[%s] ', date('Y-m-d H:i:s')) . $message; |
|
8 | - echo $message . PHP_EOL; |
|
7 | + $message = sprintf('[%s] ', date('Y-m-d H:i:s')).$message; |
|
8 | + echo $message.PHP_EOL; |
|
9 | 9 | }; |
10 | 10 | |
11 | 11 | if (!Director::is_cli()) { |
@@ -12,8 +12,8 @@ |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | public function __get($name) { |
15 | - if (method_exists($this, 'get' . $name)) { |
|
16 | - return $this->{'get' . $name}(); |
|
15 | + if (method_exists($this, 'get'.$name)) { |
|
16 | + return $this->{'get'.$name}(); |
|
17 | 17 | } |
18 | 18 | return $this->$name; |
19 | 19 | } |
@@ -12,8 +12,8 @@ |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | public function __get($name) { |
15 | - if (method_exists($this, 'get' . $name)) { |
|
16 | - return $this->{'get' . $name}(); |
|
15 | + if (method_exists($this, 'get'.$name)) { |
|
16 | + return $this->{'get'.$name}(); |
|
17 | 17 | } |
18 | 18 | return $this->$name; |
19 | 19 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | substr($sha, 0, 8), |
95 | 95 | $branch->LastUpdated()->TimeDiff() |
96 | 96 | ); |
97 | - $branches[$sha . '-' . $name] = $branchValue; |
|
97 | + $branches[$sha.'-'.$name] = $branchValue; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // Tags |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | substr($sha, 0, 8), |
108 | 108 | $branch->LastUpdated()->TimeDiff() |
109 | 109 | ); |
110 | - $tags[$sha . '-' . $name] = $tagValue; |
|
110 | + $tags[$sha.'-'.$name] = $tagValue; |
|
111 | 111 | } |
112 | 112 | $tags = array_reverse($tags); |
113 | 113 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $startedNice = null; |
41 | 41 | $startedAgo = null; |
42 | 42 | // we check first, before we do a expensive ->Nice() and ->Ago() |
43 | - if(!$deployment->DeployStarted) { |
|
43 | + if (!$deployment->DeployStarted) { |
|
44 | 44 | $started = $deployment->Created; |
45 | 45 | $startedNice = $deployment->obj('Created')->Nice(); |
46 | 46 | $startedAgo = $deployment->obj('Created')->Ago(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | self::$_cache_members[$memberID] = \DataObject::get_by_id("Member", $memberID); |
146 | 146 | } |
147 | 147 | |
148 | - if(!self::$_cache_members[$memberID]) { |
|
148 | + if (!self::$_cache_members[$memberID]) { |
|
149 | 149 | return null; |
150 | 150 | } |
151 | 151 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04” |
16 | 16 | */ |
17 | 17 | public function Format($format) { |
18 | - if($this->value){ |
|
18 | + if ($this->value) { |
|
19 | 19 | $date = new DateTime($this->value); |
20 | 20 | //if the current user has set a timezone that is not the default then use that |
21 | 21 | $member = $this->getCurrentCachedUser(); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function getCurrentCachedUser() { |
36 | 36 | $memberID = \Member::currentUserID(); |
37 | - if(!$memberID) { |
|
37 | + if (!$memberID) { |
|
38 | 38 | return null; |
39 | 39 | } |
40 | - if(!isset(self::$_cache_members[$memberID])) { |
|
40 | + if (!isset(self::$_cache_members[$memberID])) { |
|
41 | 41 | self::$_cache_members[$memberID] = Member::get()->byId($memberID); |
42 | 42 | } |
43 | 43 | return self::$_cache_members[$memberID]; |
@@ -82,11 +82,11 @@ |
||
82 | 82 | |
83 | 83 | $base = Director::absoluteBaseURL(); |
84 | 84 | return [ |
85 | - 'basename' => Director::baseURL() . $this->getCurrentEnvironment()->Link(self::ACTION_OVERVIEW), |
|
85 | + 'basename' => Director::baseURL().$this->getCurrentEnvironment()->Link(self::ACTION_OVERVIEW), |
|
86 | 86 | 'dispatchers' => [ |
87 | - 'git' => $base . $this->getCurrentProject()->Link('git'), |
|
88 | - 'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys'), |
|
89 | - 'approvals' => $base . $this->getCurrentEnvironment()->Link('approvals') |
|
87 | + 'git' => $base.$this->getCurrentProject()->Link('git'), |
|
88 | + 'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys'), |
|
89 | + 'approvals' => $base.$this->getCurrentEnvironment()->Link('approvals') |
|
90 | 90 | ], |
91 | 91 | 'api_auth' => [ |
92 | 92 | 'name' => $this->getSecurityToken()->getName(), |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | public function LogLink() { |
119 | - return $this->Link() . '/log'; |
|
119 | + return $this->Link().'/log'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function canView($member = null) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @return \Gitonomy\Git\Repository|null |
163 | 163 | */ |
164 | 164 | public function getRepository() { |
165 | - if(!$this->SHA) { |
|
165 | + if (!$this->SHA) { |
|
166 | 166 | return null; |
167 | 167 | } |
168 | 168 | return $this->Environment()->Project()->getRepository(); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function getCommit() { |
177 | 177 | $repo = $this->getRepository(); |
178 | - if($repo) { |
|
178 | + if ($repo) { |
|
179 | 179 | try { |
180 | 180 | return $this->Environment()->getCommit($this->SHA); |
181 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
181 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
182 | 182 | return null; |
183 | 183 | } |
184 | 184 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if (!$interface) { |
204 | 204 | return null; |
205 | 205 | } |
206 | - return $interface->CommitURL . '/' . $this->SHA; |
|
206 | + return $interface->CommitURL.'/'.$this->SHA; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function getCommitMessage() { |
215 | 215 | $commit = $this->getCommit(); |
216 | - if($commit) { |
|
216 | + if ($commit) { |
|
217 | 217 | try { |
218 | 218 | return Convert::raw2xml($this->Environment()->getCommitMessage($commit)); |
219 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
219 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
220 | 220 | return null; |
221 | 221 | } |
222 | 222 | } |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function getCommitSubjectMessage() { |
232 | 232 | $commit = $this->getCommit(); |
233 | - if($commit) { |
|
233 | + if ($commit) { |
|
234 | 234 | try { |
235 | 235 | return Convert::raw2xml($this->Environment()->getCommitSubjectMessage($commit)); |
236 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
236 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
237 | 237 | return null; |
238 | 238 | } |
239 | 239 | } |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function getTags() { |
249 | 249 | $commit = $this->Environment()->getCommit($this->SHA); |
250 | - if(!$commit) { |
|
250 | + if (!$commit) { |
|
251 | 251 | return new ArrayList([]); |
252 | 252 | } |
253 | 253 | $tags = $this->Environment()->getCommitTags($commit); |
254 | 254 | $returnTags = []; |
255 | 255 | if (!empty($tags)) { |
256 | - foreach($tags as $tag) { |
|
256 | + foreach ($tags as $tag) { |
|
257 | 257 | $field = Varchar::create('Tag', '255'); |
258 | 258 | $field->setValue($tag->getName()); |
259 | 259 | $returnTags[] = $field; |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function getFullDeployMessages() { |
272 | 272 | $strategy = $this->getDeploymentStrategy(); |
273 | - if ($strategy->getActionCode()!=='full') return null; |
|
273 | + if ($strategy->getActionCode() !== 'full') return null; |
|
274 | 274 | |
275 | 275 | $changes = $strategy->getChangesModificationNeeded(); |
276 | 276 | $messages = []; |
277 | 277 | foreach ($changes as $change => $details) { |
278 | - if ($change==='Code version') continue; |
|
278 | + if ($change === 'Code version') continue; |
|
279 | 279 | |
280 | 280 | $messages[] = [ |
281 | 281 | 'Flag' => sprintf( |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function getTag() { |
305 | 305 | $tags = $this->getTags(); |
306 | - if($tags->count() > 0) { |
|
306 | + if ($tags->count() > 0) { |
|
307 | 307 | return $tags->last(); |
308 | 308 | } |
309 | 309 | return null; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | public function getChanges() { |
329 | 329 | $list = new ArrayList(); |
330 | 330 | $strategy = $this->getDeploymentStrategy(); |
331 | - foreach($strategy->getChanges() as $name => $change) { |
|
331 | + foreach ($strategy->getChanges() as $name => $change) { |
|
332 | 332 | $changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null; |
333 | 333 | $description = isset($change['description']) ? $change['description'] : ''; |
334 | 334 | $compareUrl = null; |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | // Make sure we use the SHA as it was written into this DNDeployment. |
379 | 379 | $args['sha'] = $this->SHA; |
380 | 380 | |
381 | - if(!$this->DeployerID) { |
|
381 | + if (!$this->DeployerID) { |
|
382 | 382 | $this->DeployerID = Member::currentUserID(); |
383 | 383 | } |
384 | 384 | |
385 | - if($this->DeployerID) { |
|
385 | + if ($this->DeployerID) { |
|
386 | 386 | $deployer = $this->Deployer(); |
387 | 387 | $message = sprintf( |
388 | 388 | 'Deploy to %s initiated by %s (%s), with IP address %s', |