@@ -19,27 +19,27 @@ |
||
19 | 19 | * |
20 | 20 | */ |
21 | 21 | public function perform() { |
22 | - echo "[-] CreateEnvJob starting" . PHP_EOL; |
|
22 | + echo "[-] CreateEnvJob starting".PHP_EOL; |
|
23 | 23 | |
24 | 24 | $log = new DeploynautLogFile($this->args['logfile']); |
25 | 25 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
26 | 26 | |
27 | 27 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
28 | 28 | try { |
29 | - if(!($envCreate && $envCreate->exists())) { |
|
29 | + if (!($envCreate && $envCreate->exists())) { |
|
30 | 30 | throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID'])); |
31 | 31 | } |
32 | 32 | |
33 | 33 | // This will throw and exception if it fails. |
34 | 34 | $envCreate->createEnvironment(); |
35 | 35 | |
36 | - } catch(Exception $e) { |
|
36 | + } catch (Exception $e) { |
|
37 | 37 | $log->write($e->getMessage()); |
38 | - echo "[-] CreateEnvJob failed" . PHP_EOL; |
|
38 | + echo "[-] CreateEnvJob failed".PHP_EOL; |
|
39 | 39 | throw $e; |
40 | 40 | } |
41 | 41 | $this->updateStatus('Finished'); |
42 | - echo "[-] CreateEnvJob finished" . PHP_EOL; |
|
42 | + echo "[-] CreateEnvJob finished".PHP_EOL; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | Requirements::javascript('deploynaut/javascript/material.js'); |
180 | 180 | |
181 | 181 | // Load the buildable dependencies only if not loaded centrally. |
182 | - if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { |
|
182 | + if (!is_dir(BASE_PATH.DIRECTORY_SEPARATOR.'static')) { |
|
183 | 183 | if (\Director::isDev()) { |
184 | 184 | \Requirements::javascript('deploynaut/static/bundle-debug.js'); |
185 | 185 | } else { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | // Block framework jquery |
246 | - Requirements::block(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); |
|
246 | + Requirements::block(FRAMEWORK_DIR.'/thirdparty/jquery/jquery.js'); |
|
247 | 247 | |
248 | 248 | self::include_requirements(); |
249 | 249 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return \SS_HTTPResponse |
263 | 263 | */ |
264 | 264 | public function index(SS_HTTPRequest $request) { |
265 | - return $this->redirect($this->Link() . 'projects/'); |
|
265 | + return $this->redirect($this->Link().'projects/'); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | // Framing an environment as a "group of people with download access" |
391 | 391 | // makes more sense to the user here, while still allowing us to enforce |
392 | 392 | // environment specific restrictions on downloading the file later on. |
393 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
393 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
394 | 394 | return $item->canUploadArchive(); |
395 | 395 | }); |
396 | 396 | $envsMap = []; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $form->disableSecurityToken(); |
423 | 423 | $form->addExtraClass('fields-wide'); |
424 | 424 | // Tweak the action so it plays well with our fake URL structure. |
425 | - $form->setFormAction($project->Link() . '/UploadSnapshotForm'); |
|
425 | + $form->setFormAction($project->Link().'/UploadSnapshotForm'); |
|
426 | 426 | |
427 | 427 | return $form; |
428 | 428 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | $validEnvs = $project->DNEnvironmentList() |
446 | - ->filterByCallback(function ($item) { |
|
446 | + ->filterByCallback(function($item) { |
|
447 | 447 | return $item->canUploadArchive(); |
448 | 448 | }); |
449 | 449 | |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | $dataArchive->DataTransfers()->add($dataTransfer); |
473 | 473 | $form->saveInto($dataArchive); |
474 | 474 | $dataArchive->write(); |
475 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
475 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
476 | 476 | |
477 | - $cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) { |
|
477 | + $cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) { |
|
478 | 478 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
479 | 479 | $process->setTimeout(120); |
480 | 480 | $process->run(); |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | // Framing an environment as a "group of people with download access" |
549 | 549 | // makes more sense to the user here, while still allowing us to enforce |
550 | 550 | // environment specific restrictions on downloading the file later on. |
551 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
551 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
552 | 552 | return $item->canUploadArchive(); |
553 | 553 | }); |
554 | 554 | $envsMap = []; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $form->disableSecurityToken(); |
575 | 575 | $form->addExtraClass('fields-wide'); |
576 | 576 | // Tweak the action so it plays well with our fake URL structure. |
577 | - $form->setFormAction($project->Link() . '/PostSnapshotForm'); |
|
577 | + $form->setFormAction($project->Link().'/PostSnapshotForm'); |
|
578 | 578 | |
579 | 579 | return $form; |
580 | 580 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | return $this->project404Response(); |
594 | 594 | } |
595 | 595 | |
596 | - $validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
596 | + $validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
597 | 597 | return $item->canUploadArchive(); |
598 | 598 | }); |
599 | 599 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $branchName = $request->getVar('name'); |
714 | 714 | $branch = $project->DNBranchList()->byName($branchName); |
715 | 715 | if (!$branch) { |
716 | - return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404); |
|
716 | + return new SS_HTTPResponse("Branch '".Convert::raw2xml($branchName)."' not found.", 404); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | return $this->render([ |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | ); |
851 | 851 | |
852 | 852 | // Tweak the action so it plays well with our fake URL structure. |
853 | - $form->setFormAction($project->Link() . '/CreateEnvironmentForm'); |
|
853 | + $form->setFormAction($project->Link().'/CreateEnvironmentForm'); |
|
854 | 854 | |
855 | 855 | return $form; |
856 | 856 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | $job->write(); |
884 | 884 | $job->start(); |
885 | 885 | |
886 | - return $this->redirect($project->Link('createenv') . '/' . $job->ID); |
|
886 | + return $this->redirect($project->Link('createenv').'/'.$job->ID); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | return $body; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - $form->setFormAction($this->getRequest()->getURL() . '/DeployForm'); |
|
1084 | + $form->setFormAction($this->getRequest()->getURL().'/DeployForm'); |
|
1085 | 1085 | return $form; |
1086 | 1086 | } |
1087 | 1087 | |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | $deployment->getMachine()->apply(DNDeployment::TR_QUEUE); |
1348 | 1348 | |
1349 | 1349 | return json_encode([ |
1350 | - 'url' => Director::absoluteBaseURL() . $deployment->Link() |
|
1350 | + 'url' => Director::absoluteBaseURL().$deployment->Link() |
|
1351 | 1351 | ], JSON_PRETTY_PRINT); |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | */ |
1471 | 1471 | public function getDataTransferForm(SS_HTTPRequest $request = null) { |
1472 | 1472 | // Performs canView permission check by limiting visible projects |
1473 | - $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) { |
|
1473 | + $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) { |
|
1474 | 1474 | return $item->canBackup(); |
1475 | 1475 | }); |
1476 | 1476 | |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | |
1481 | 1481 | $items = []; |
1482 | 1482 | $disabledEnvironments = []; |
1483 | - foreach($envs as $env) { |
|
1483 | + foreach ($envs as $env) { |
|
1484 | 1484 | $items[$env->ID] = $env->Title; |
1485 | 1485 | if ($env->CurrentBuild() === false) { |
1486 | 1486 | $items[$env->ID] = sprintf("%s - requires initial deployment", $env->Title); |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | } |
1489 | 1489 | } |
1490 | 1490 | |
1491 | - $envsField = DropdownField::create('EnvironmentID', 'Environment', $items) |
|
1491 | + $envsField = DropdownField::create('EnvironmentID', 'Environment', $items) |
|
1492 | 1492 | ->setEmptyString('Select an environment'); |
1493 | 1493 | $envsField->setDisabledItems($disabledEnvironments); |
1494 | 1494 | |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | ), |
1510 | 1510 | FieldList::create($formAction) |
1511 | 1511 | ); |
1512 | - $form->setFormAction($this->getRequest()->getURL() . '/DataTransferForm'); |
|
1512 | + $form->setFormAction($this->getRequest()->getURL().'/DataTransferForm'); |
|
1513 | 1513 | |
1514 | 1514 | return $form; |
1515 | 1515 | } |
@@ -1535,12 +1535,12 @@ discard block |
||
1535 | 1535 | // Validate direction. |
1536 | 1536 | if ($data['Direction'] == 'get') { |
1537 | 1537 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
1538 | - ->filterByCallback(function ($item) { |
|
1538 | + ->filterByCallback(function($item) { |
|
1539 | 1539 | return $item->canBackup(); |
1540 | 1540 | }); |
1541 | 1541 | } else if ($data['Direction'] == 'push') { |
1542 | 1542 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
1543 | - ->filterByCallback(function ($item) { |
|
1543 | + ->filterByCallback(function($item) { |
|
1544 | 1544 | return $item->canRestore(); |
1545 | 1545 | }); |
1546 | 1546 | } else { |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | // Performs canView permission check by limiting visible projects |
1673 | 1673 | $project = $this->getCurrentProject(); |
1674 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
1674 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
1675 | 1675 | return $item->canRestore(); |
1676 | 1676 | }); |
1677 | 1677 | |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | |
1697 | 1697 | $items = []; |
1698 | 1698 | $disabledEnvironments = []; |
1699 | - foreach($envs as $env) { |
|
1699 | + foreach ($envs as $env) { |
|
1700 | 1700 | $items[$env->ID] = $env->Title; |
1701 | 1701 | if ($env->CurrentBuild() === false) { |
1702 | 1702 | $items[$env->ID] = sprintf("%s - requires initial deployment", $env->Title); |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | ), |
1726 | 1726 | FieldList::create($formAction) |
1727 | 1727 | ); |
1728 | - $form->setFormAction($project->Link() . '/DataTransferRestoreForm'); |
|
1728 | + $form->setFormAction($project->Link().'/DataTransferRestoreForm'); |
|
1729 | 1729 | |
1730 | 1730 | return $form; |
1731 | 1731 | } |
@@ -1823,7 +1823,7 @@ discard block |
||
1823 | 1823 | ->addExtraClass('btn') |
1824 | 1824 | ) |
1825 | 1825 | ); |
1826 | - $form->setFormAction($project->Link() . '/DeleteForm'); |
|
1826 | + $form->setFormAction($project->Link().'/DeleteForm'); |
|
1827 | 1827 | |
1828 | 1828 | return $form; |
1829 | 1829 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | ->addExtraClass('btn') |
1930 | 1930 | ) |
1931 | 1931 | ); |
1932 | - $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm'); |
|
1932 | + $form->setFormAction($this->getCurrentProject()->Link().'/MoveForm'); |
|
1933 | 1933 | |
1934 | 1934 | return $form; |
1935 | 1935 | } |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | $transfers = DNDataTransfer::get() |
2191 | 2191 | ->filter('EnvironmentID', $environments) |
2192 | 2192 | ->filterByCallback( |
2193 | - function ($record) { |
|
2193 | + function($record) { |
|
2194 | 2194 | return |
2195 | 2195 | $record->Environment()->canRestore() || // Ensure member can perform an action on the transfers env |
2196 | 2196 | $record->Environment()->canBackup() || |
@@ -2315,7 +2315,7 @@ discard block |
||
2315 | 2315 | */ |
2316 | 2316 | protected function project404Response() { |
2317 | 2317 | return new SS_HTTPResponse( |
2318 | - "Project '" . Convert::raw2xml($this->getRequest()->param('Project')) . "' not found.", |
|
2318 | + "Project '".Convert::raw2xml($this->getRequest()->param('Project'))."' not found.", |
|
2319 | 2319 | 404 |
2320 | 2320 | ); |
2321 | 2321 | } |
@@ -2325,7 +2325,7 @@ discard block |
||
2325 | 2325 | */ |
2326 | 2326 | protected function environment404Response() { |
2327 | 2327 | $envName = Convert::raw2xml($this->getRequest()->param('Environment')); |
2328 | - return new SS_HTTPResponse("Environment '" . $envName . "' not found.", 404); |
|
2328 | + return new SS_HTTPResponse("Environment '".$envName."' not found.", 404); |
|
2329 | 2329 | } |
2330 | 2330 | |
2331 | 2331 | /** |
@@ -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()) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | public function LogLink() { |
114 | - return $this->Link() . '/log'; |
|
114 | + return $this->Link().'/log'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function canView($member = null) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return \Gitonomy\Git\Repository|null |
158 | 158 | */ |
159 | 159 | public function getRepository() { |
160 | - if(!$this->SHA) { |
|
160 | + if (!$this->SHA) { |
|
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | return $this->Environment()->Project()->getRepository(); |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function getCommit() { |
172 | 172 | $repo = $this->getRepository(); |
173 | - if($repo) { |
|
173 | + if ($repo) { |
|
174 | 174 | try { |
175 | 175 | return $this->Environment()->getCommit($this->SHA); |
176 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
176 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
177 | 177 | return null; |
178 | 178 | } |
179 | 179 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | if (!$interface) { |
199 | 199 | return null; |
200 | 200 | } |
201 | - return $interface->CommitURL . '/' . $this->SHA; |
|
201 | + return $interface->CommitURL.'/'.$this->SHA; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getCommitMessage() { |
210 | 210 | $commit = $this->getCommit(); |
211 | - if($commit) { |
|
211 | + if ($commit) { |
|
212 | 212 | try { |
213 | 213 | return Convert::raw2xml($this->Environment()->getCommitMessage($commit)); |
214 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
214 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
215 | 215 | return null; |
216 | 216 | } |
217 | 217 | } |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getTags() { |
227 | 227 | $commit = $this->Environment()->getCommit($this->SHA); |
228 | - if(!$commit) { |
|
228 | + if (!$commit) { |
|
229 | 229 | return new ArrayList([]); |
230 | 230 | } |
231 | 231 | $tags = $this->Environment()->getCommitTags($commit); |
232 | 232 | $returnTags = []; |
233 | 233 | if (!empty($tags)) { |
234 | - foreach($tags as $tag) { |
|
234 | + foreach ($tags as $tag) { |
|
235 | 235 | $field = Varchar::create('Tag', '255'); |
236 | 236 | $field->setValue($tag->getName()); |
237 | 237 | $returnTags[] = $field; |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function getFullDeployMessages() { |
250 | 250 | $strategy = $this->getDeploymentStrategy(); |
251 | - if ($strategy->getActionCode()!=='full') return null; |
|
251 | + if ($strategy->getActionCode() !== 'full') return null; |
|
252 | 252 | |
253 | 253 | $changes = $strategy->getChangesModificationNeeded(); |
254 | 254 | $messages = []; |
255 | 255 | foreach ($changes as $change => $details) { |
256 | - if ($change==='Code version') continue; |
|
256 | + if ($change === 'Code version') continue; |
|
257 | 257 | |
258 | 258 | $messages[] = [ |
259 | 259 | 'Flag' => sprintf( |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function getTag() { |
283 | 283 | $tags = $this->getTags(); |
284 | - if($tags->count() > 0) { |
|
284 | + if ($tags->count() > 0) { |
|
285 | 285 | return $tags->last(); |
286 | 286 | } |
287 | 287 | return null; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function getChanges() { |
307 | 307 | $list = new ArrayList(); |
308 | 308 | $strategy = $this->getDeploymentStrategy(); |
309 | - foreach($strategy->getChanges() as $name => $change) { |
|
309 | + foreach ($strategy->getChanges() as $name => $change) { |
|
310 | 310 | $changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null; |
311 | 311 | $description = isset($change['description']) ? $change['description'] : ''; |
312 | 312 | $compareUrl = null; |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | // Make sure we use the SHA as it was written into this DNDeployment. |
357 | 357 | $args['sha'] = $this->SHA; |
358 | 358 | |
359 | - if(!$this->DeployerID) { |
|
359 | + if (!$this->DeployerID) { |
|
360 | 360 | $this->DeployerID = Member::currentUserID(); |
361 | 361 | } |
362 | 362 | |
363 | - if($this->DeployerID) { |
|
363 | + if ($this->DeployerID) { |
|
364 | 364 | $deployer = $this->Deployer(); |
365 | 365 | $message = sprintf( |
366 | 366 | 'Deploy to %s initiated by %s (%s), with IP address %s', |
@@ -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 |