@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Base class for the APINouns |
|
| 4 | - */ |
|
| 3 | + * Base class for the APINouns |
|
| 4 | + */ |
|
| 5 | 5 | class APINoun extends Controller { |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | * @return SS_HTTPResponse |
| 120 | 120 | */ |
| 121 | 121 | protected function message($message, $statusCode) { |
| 122 | - $response = $this->getAPIResponse(array( |
|
| 122 | + $response = $this->getAPIResponse(array( |
|
| 123 | 123 | 'message' => $message, |
| 124 | 124 | 'statusCode' => $statusCode |
| 125 | 125 | )); |
@@ -954,7 +954,7 @@ |
||
| 954 | 954 | to other environments, alongside the "Who can restore" permission.<br> |
| 955 | 955 | Should include all users with upload permissions, otherwise they can't download |
| 956 | 956 | their own uploads. |
| 957 | -PHP |
|
| 957 | +php |
|
| 958 | 958 | ), |
| 959 | 959 | |
| 960 | 960 | // The Main.PipelineApprovers |
@@ -919,6 +919,9 @@ |
||
| 919 | 919 | $fields->insertAfter($createConfigField, 'noDeployConfig'); |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | + /** |
|
| 923 | + * @param FieldList $fields |
|
| 924 | + */ |
|
| 922 | 925 | protected function setPipelineConfigurationFields($fields) { |
| 923 | 926 | if(!$this->config()->get('allow_web_editing')) { |
| 924 | 927 | return; |
@@ -180,19 +180,19 @@ |
||
| 180 | 180 | $backends = array_keys($this->config()->get('allowed_backends', Config::FIRST_SET)); |
| 181 | 181 | switch(sizeof($backends)) { |
| 182 | 182 | // Nothing allowed, use the default value "DeploymentBackend" |
| 183 | - case 0: |
|
| 184 | - $backend = "DeploymentBackend"; |
|
| 185 | - break; |
|
| 186 | - |
|
| 187 | - // Only 1 thing allowed, use that |
|
| 188 | - case 1: |
|
| 189 | - $backend = $backends[0]; |
|
| 190 | - break; |
|
| 191 | - |
|
| 192 | - // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list |
|
| 193 | - default: |
|
| 194 | - $backend = $this->BackendIdentifier; |
|
| 195 | - if(!in_array($backend, $backends)) $backend = $backends[0]; |
|
| 183 | + case 0: |
|
| 184 | + $backend = "DeploymentBackend"; |
|
| 185 | + break; |
|
| 186 | + |
|
| 187 | + // Only 1 thing allowed, use that |
|
| 188 | + case 1: |
|
| 189 | + $backend = $backends[0]; |
|
| 190 | + break; |
|
| 191 | + |
|
| 192 | + // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list |
|
| 193 | + default: |
|
| 194 | + $backend = $this->BackendIdentifier; |
|
| 195 | + if(!in_array($backend, $backends)) $backend = $backends[0]; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return Injector::inst()->get($backend); |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | "CanBackupGroups" => "Group", |
| 108 | 108 | "ArchiveUploaders" => "Member", // Who can upload archive files linked to this environment |
| 109 | 109 | "ArchiveUploaderGroups" => "Group", |
| 110 | - "ArchiveDownloaders" => "Member", // Who can download archive files from this environment |
|
| 110 | + "ArchiveDownloaders" => "Member", // Who can download archive files from this environment |
|
| 111 | 111 | "ArchiveDownloaderGroups" => "Group", |
| 112 | - "ArchiveDeleters" => "Member", // Who can delete archive files from this environment, |
|
| 112 | + "ArchiveDeleters" => "Member", // Who can delete archive files from this environment, |
|
| 113 | 113 | "ArchiveDeleterGroups" => "Group", |
| 114 | 114 | "PipelineApprovers" => "Member", // Who can approve / reject pipelines from this environment |
| 115 | 115 | "PipelineApproverGroups" => "Group", |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function CanCancelPipeline() { |
| 293 | 293 | // do we have a current pipeline |
| 294 | - if ($this->HasCurrentPipeline()) { |
|
| 294 | + if($this->HasCurrentPipeline()) { |
|
| 295 | 295 | return $this->CurrentPipeline()->canAbort(); |
| 296 | 296 | } |
| 297 | 297 | return false; |
@@ -599,22 +599,22 @@ discard block |
||
| 599 | 599 | // The DeployHistory function is far too slow to use for this |
| 600 | 600 | $deploy = DNDeployment::get()->filter(array('EnvironmentID' => $this->ID, 'Status' => 'Finished'))->sort('LastEdited DESC')->first(); |
| 601 | 601 | |
| 602 | - if (!$deploy || (!$deploy->SHA)) { |
|
| 602 | + if(!$deploy || (!$deploy->SHA)) { |
|
| 603 | 603 | return false; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | $repo = $this->Project()->getRepository(); |
| 607 | - if (!$repo) { |
|
| 607 | + if(!$repo) { |
|
| 608 | 608 | return $deploy; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | try { |
| 612 | 612 | $commit = $repo->getCommit($deploy->SHA); |
| 613 | - if ($commit) { |
|
| 613 | + if($commit) { |
|
| 614 | 614 | $deploy->Message = Convert::raw2xml($commit->getMessage()); |
| 615 | 615 | } |
| 616 | 616 | // We can't find this SHA, so we ignore adding a commit message to the deployment |
| 617 | - } catch (Exception $ex) { } |
|
| 617 | + } catch(Exception $ex) { } |
|
| 618 | 618 | |
| 619 | 619 | return $deploy; |
| 620 | 620 | } |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | $deploy->Message = Convert::raw2xml($commit->getMessage()); |
| 645 | 645 | } |
| 646 | 646 | // We can't find this SHA, so we ignore adding a commit message to the deployment |
| 647 | - } catch (Exception $ex) { } |
|
| 647 | + } catch(Exception $ex) { } |
|
| 648 | 648 | $ammendedHistory->push($deploy); |
| 649 | 649 | } |
| 650 | 650 | |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | * @return string |
| 683 | 683 | */ |
| 684 | 684 | public function Link() { |
| 685 | - return $this->Project()->Link()."/environment/" . $this->Name; |
|
| 685 | + return $this->Project()->Link() . "/environment/" . $this->Name; |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | // Add actions |
| 888 | 888 | $action = new FormAction('check', 'Check Connection'); |
| 889 | 889 | $action->setUseButtonTag(true); |
| 890 | - $action->setAttribute('data-url', Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'); |
|
| 890 | + $action->setAttribute('data-url', Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'); |
|
| 891 | 891 | $fields->insertBefore($action, 'Name'); |
| 892 | 892 | |
| 893 | 893 | // Allow extensions |
@@ -950,8 +950,8 @@ discard block |
||
| 950 | 950 | */ |
| 951 | 951 | public function onBeforeWrite() { |
| 952 | 952 | parent::onBeforeWrite(); |
| 953 | - if($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
| 954 | - $this->Filename = $this->Name.'.rb'; |
|
| 953 | + if($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
| 954 | + $this->Filename = $this->Name . '.rb'; |
|
| 955 | 955 | } |
| 956 | 956 | $this->checkEnvironmentPath(); |
| 957 | 957 | $this->writeConfigFile(); |
@@ -976,11 +976,11 @@ discard block |
||
| 976 | 976 | if(!$this->config()->get('allow_web_editing')) return; |
| 977 | 977 | |
| 978 | 978 | // Create a basic new environment config from a template |
| 979 | - if( !$this->envFileExists() |
|
| 979 | + if(!$this->envFileExists() |
|
| 980 | 980 | && $this->Filename |
| 981 | 981 | && $this->CreateEnvConfig |
| 982 | 982 | ) { |
| 983 | - $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
| 983 | + $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
| 984 | 984 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
| 985 | 985 | } else if($this->envFileExists() && $this->DeployConfig) { |
| 986 | 986 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | if(!$this->Filename) { |
| 1048 | 1048 | return ''; |
| 1049 | 1049 | } |
| 1050 | - return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
| 1050 | + return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1126,10 +1126,10 @@ discard block |
||
| 1126 | 1126 | $filter = isset($config->PipelineConfig->FilteredCommits) |
| 1127 | 1127 | ? $config->PipelineConfig->FilteredCommits |
| 1128 | 1128 | : null; |
| 1129 | - if (empty($filter)) return null; |
|
| 1129 | + if(empty($filter)) return null; |
|
| 1130 | 1130 | |
| 1131 | 1131 | // Create and execute filter |
| 1132 | - if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1132 | + if(!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1133 | 1133 | $commitClass = $filter::create(); |
| 1134 | 1134 | // setup the environment to check for commits |
| 1135 | 1135 | $commitClass->env = $dependsOnEnv; |
@@ -192,7 +192,9 @@ discard block |
||
| 192 | 192 | // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list |
| 193 | 193 | default: |
| 194 | 194 | $backend = $this->BackendIdentifier; |
| 195 | - if(!in_array($backend, $backends)) $backend = $backends[0]; |
|
| 195 | + if(!in_array($backend, $backends)) { |
|
| 196 | + $backend = $backends[0]; |
|
| 197 | + } |
|
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | return Injector::inst()->get($backend); |
@@ -304,10 +306,17 @@ discard block |
||
| 304 | 306 | * @return boolean |
| 305 | 307 | */ |
| 306 | 308 | public function canView($member = null) { |
| 307 | - if(!$member) $member = Member::currentUser(); |
|
| 308 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 309 | + if(!$member) { |
|
| 310 | + $member = Member::currentUser(); |
|
| 311 | + } |
|
| 312 | + if(!$member) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + // Must be logged in to check permissions |
|
| 309 | 316 | |
| 310 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 317 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 318 | + return true; |
|
| 319 | + } |
|
| 311 | 320 | |
| 312 | 321 | // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions |
| 313 | 322 | if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { |
@@ -325,10 +334,17 @@ discard block |
||
| 325 | 334 | * @return boolean |
| 326 | 335 | */ |
| 327 | 336 | public function canDeploy($member = null) { |
| 328 | - if(!$member) $member = Member::currentUser(); |
|
| 329 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 337 | + if(!$member) { |
|
| 338 | + $member = Member::currentUser(); |
|
| 339 | + } |
|
| 340 | + if(!$member) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + // Must be logged in to check permissions |
|
| 330 | 344 | |
| 331 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 345 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 346 | + return true; |
|
| 347 | + } |
|
| 332 | 348 | |
| 333 | 349 | return $this->Deployers()->byID($member->ID) |
| 334 | 350 | || $member->inGroups($this->DeployerGroups()); |
@@ -342,10 +358,17 @@ discard block |
||
| 342 | 358 | * @return boolean true if $member can restore, and false if they can't. |
| 343 | 359 | */ |
| 344 | 360 | public function canRestore($member = null) { |
| 345 | - if(!$member) $member = Member::currentUser(); |
|
| 346 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 361 | + if(!$member) { |
|
| 362 | + $member = Member::currentUser(); |
|
| 363 | + } |
|
| 364 | + if(!$member) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 367 | + // Must be logged in to check permissions |
|
| 347 | 368 | |
| 348 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 369 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 370 | + return true; |
|
| 371 | + } |
|
| 349 | 372 | |
| 350 | 373 | return $this->CanRestoreMembers()->byID($member->ID) |
| 351 | 374 | || $member->inGroups($this->CanRestoreGroups()); |
@@ -360,12 +383,21 @@ discard block |
||
| 360 | 383 | */ |
| 361 | 384 | public function canBackup($member = null) { |
| 362 | 385 | $project = $this->Project(); |
| 363 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) return false; |
|
| 386 | + if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 364 | 389 | |
| 365 | - if(!$member) $member = Member::currentUser(); |
|
| 366 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 390 | + if(!$member) { |
|
| 391 | + $member = Member::currentUser(); |
|
| 392 | + } |
|
| 393 | + if(!$member) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 396 | + // Must be logged in to check permissions |
|
| 367 | 397 | |
| 368 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 398 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 399 | + return true; |
|
| 400 | + } |
|
| 369 | 401 | |
| 370 | 402 | return $this->CanBackupMembers()->byID($member->ID) |
| 371 | 403 | || $member->inGroups($this->CanBackupGroups()); |
@@ -384,12 +416,21 @@ discard block |
||
| 384 | 416 | */ |
| 385 | 417 | public function canUploadArchive($member = null) { |
| 386 | 418 | $project = $this->Project(); |
| 387 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) return false; |
|
| 419 | + if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 420 | + return false; |
|
| 421 | + } |
|
| 388 | 422 | |
| 389 | - if(!$member) $member = Member::currentUser(); |
|
| 390 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 423 | + if(!$member) { |
|
| 424 | + $member = Member::currentUser(); |
|
| 425 | + } |
|
| 426 | + if(!$member) { |
|
| 427 | + return false; |
|
| 428 | + } |
|
| 429 | + // Must be logged in to check permissions |
|
| 391 | 430 | |
| 392 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 431 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 432 | + return true; |
|
| 433 | + } |
|
| 393 | 434 | |
| 394 | 435 | return $this->ArchiveUploaders()->byID($member->ID) |
| 395 | 436 | || $member->inGroups($this->ArchiveUploaderGroups()); |
@@ -403,10 +444,17 @@ discard block |
||
| 403 | 444 | * @return boolean true if $member can download archives from this environment, false if they can't. |
| 404 | 445 | */ |
| 405 | 446 | public function canDownloadArchive($member = null) { |
| 406 | - if(!$member) $member = Member::currentUser(); |
|
| 407 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 447 | + if(!$member) { |
|
| 448 | + $member = Member::currentUser(); |
|
| 449 | + } |
|
| 450 | + if(!$member) { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 453 | + // Must be logged in to check permissions |
|
| 408 | 454 | |
| 409 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 455 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 456 | + return true; |
|
| 457 | + } |
|
| 410 | 458 | return $this->ArchiveDownloaders()->byID($member->ID) |
| 411 | 459 | || $member->inGroups($this->ArchiveDownloaderGroups()); |
| 412 | 460 | } |
@@ -418,10 +466,16 @@ discard block |
||
| 418 | 466 | * @return boolean |
| 419 | 467 | */ |
| 420 | 468 | public function canAbort($member = null) { |
| 421 | - if(!$member) $member = Member::currentUser(); |
|
| 422 | - if(!$member) return false; |
|
| 469 | + if(!$member) { |
|
| 470 | + $member = Member::currentUser(); |
|
| 471 | + } |
|
| 472 | + if(!$member) { |
|
| 473 | + return false; |
|
| 474 | + } |
|
| 423 | 475 | |
| 424 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 476 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 477 | + return true; |
|
| 478 | + } |
|
| 425 | 479 | |
| 426 | 480 | return $this->PipelineCancellers()->byID($member->ID) |
| 427 | 481 | || $member->inGroups($this->PipelineCancellerGroups()); |
@@ -434,10 +488,16 @@ discard block |
||
| 434 | 488 | * @return boolean |
| 435 | 489 | */ |
| 436 | 490 | public function canApprove($member = null) { |
| 437 | - if(!$member) $member = Member::currentUser(); |
|
| 438 | - if(!$member) return false; |
|
| 491 | + if(!$member) { |
|
| 492 | + $member = Member::currentUser(); |
|
| 493 | + } |
|
| 494 | + if(!$member) { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 439 | 497 | |
| 440 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 498 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 499 | + return true; |
|
| 500 | + } |
|
| 441 | 501 | return $this->PipelineApprovers()->byID($member->ID) |
| 442 | 502 | || $member->inGroups($this->PipelineApproverGroups()); |
| 443 | 503 | } |
@@ -450,10 +510,17 @@ discard block |
||
| 450 | 510 | * @return boolean true if $member can delete archives from this environment, false if they can't. |
| 451 | 511 | */ |
| 452 | 512 | public function canDeleteArchive($member = null) { |
| 453 | - if(!$member) $member = Member::currentUser(); |
|
| 454 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 513 | + if(!$member) { |
|
| 514 | + $member = Member::currentUser(); |
|
| 515 | + } |
|
| 516 | + if(!$member) { |
|
| 517 | + return false; |
|
| 518 | + } |
|
| 519 | + // Must be logged in to check permissions |
|
| 455 | 520 | |
| 456 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 521 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 522 | + return true; |
|
| 523 | + } |
|
| 457 | 524 | |
| 458 | 525 | return $this->ArchiveDeleters()->byID($member->ID) |
| 459 | 526 | || $member->inGroups($this->ArchiveDeleterGroups()); |
@@ -973,7 +1040,9 @@ discard block |
||
| 973 | 1040 | * Write the deployment config file to filesystem |
| 974 | 1041 | */ |
| 975 | 1042 | protected function writeConfigFile() { |
| 976 | - if(!$this->config()->get('allow_web_editing')) return; |
|
| 1043 | + if(!$this->config()->get('allow_web_editing')) { |
|
| 1044 | + return; |
|
| 1045 | + } |
|
| 977 | 1046 | |
| 978 | 1047 | // Create a basic new environment config from a template |
| 979 | 1048 | if( !$this->envFileExists() |
@@ -991,7 +1060,9 @@ discard block |
||
| 991 | 1060 | * Write the pipeline config file to filesystem |
| 992 | 1061 | */ |
| 993 | 1062 | protected function writePipelineFile() { |
| 994 | - if(!$this->config()->get('allow_web_editing')) return; |
|
| 1063 | + if(!$this->config()->get('allow_web_editing')) { |
|
| 1064 | + return; |
|
| 1065 | + } |
|
| 995 | 1066 | $path = $this->getPipelineFilename(); |
| 996 | 1067 | if($this->PipelineConfig) { |
| 997 | 1068 | // Update file |
@@ -1058,9 +1129,13 @@ discard block |
||
| 1058 | 1129 | */ |
| 1059 | 1130 | public function getPipelineFilename() { |
| 1060 | 1131 | $name = $this->getConfigFilename(); |
| 1061 | - if(!$name) return null; |
|
| 1132 | + if(!$name) { |
|
| 1133 | + return null; |
|
| 1134 | + } |
|
| 1062 | 1135 | $path = pathinfo($name); |
| 1063 | - if($path) return $path['dirname'] . '/' . $path['filename'] . '.yml'; |
|
| 1136 | + if($path) { |
|
| 1137 | + return $path['dirname'] . '/' . $path['filename'] . '.yml'; |
|
| 1138 | + } |
|
| 1064 | 1139 | } |
| 1065 | 1140 | |
| 1066 | 1141 | /** |
@@ -1086,7 +1161,9 @@ discard block |
||
| 1086 | 1161 | */ |
| 1087 | 1162 | public static function array_to_viewabledata($array) { |
| 1088 | 1163 | // Don't transform non-arrays |
| 1089 | - if(!is_array($array)) return $array; |
|
| 1164 | + if(!is_array($array)) { |
|
| 1165 | + return $array; |
|
| 1166 | + } |
|
| 1090 | 1167 | |
| 1091 | 1168 | // Figure out whether this is indexed or associative |
| 1092 | 1169 | $keys = array_keys($array); |
@@ -1119,17 +1196,23 @@ discard block |
||
| 1119 | 1196 | public function getDependentFilteredCommits() { |
| 1120 | 1197 | // check if this environment depends on another environemnt |
| 1121 | 1198 | $dependsOnEnv = $this->DependsOnEnvironment(); |
| 1122 | - if(empty($dependsOnEnv)) return null; |
|
| 1199 | + if(empty($dependsOnEnv)) { |
|
| 1200 | + return null; |
|
| 1201 | + } |
|
| 1123 | 1202 | |
| 1124 | 1203 | // Check if there is a filter |
| 1125 | 1204 | $config = $this->GenericPipelineConfig(); |
| 1126 | 1205 | $filter = isset($config->PipelineConfig->FilteredCommits) |
| 1127 | 1206 | ? $config->PipelineConfig->FilteredCommits |
| 1128 | 1207 | : null; |
| 1129 | - if (empty($filter)) return null; |
|
| 1208 | + if (empty($filter)) { |
|
| 1209 | + return null; |
|
| 1210 | + } |
|
| 1130 | 1211 | |
| 1131 | 1212 | // Create and execute filter |
| 1132 | - if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1213 | + if (!class_exists($filter)) { |
|
| 1214 | + throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1215 | + } |
|
| 1133 | 1216 | $commitClass = $filter::create(); |
| 1134 | 1217 | // setup the environment to check for commits |
| 1135 | 1218 | $commitClass->env = $dependsOnEnv; |
@@ -257,7 +257,7 @@ |
||
| 257 | 257 | * @return string |
| 258 | 258 | */ |
| 259 | 259 | public function getTitle() { |
| 260 | - return "Pipeline {$this->ID} (Status: {$this->Status})"; |
|
| 260 | + return "pipeline {$this->ID} (Status: {$this->Status})"; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -368,7 +368,6 @@ discard block |
||
| 368 | 368 | * Retrieve the value of a specific config setting |
| 369 | 369 | * |
| 370 | 370 | * @param string $setting Settings |
| 371 | - * @param string $setting,... Sub-settings |
|
| 372 | 371 | * @return mixed Value of setting, or null if not set |
| 373 | 372 | */ |
| 374 | 373 | public function getConfigSetting($setting) { |
@@ -773,7 +772,7 @@ discard block |
||
| 773 | 772 | * Sends a specific message to all marked recipients, including the author of this pipeline |
| 774 | 773 | * |
| 775 | 774 | * @param string $messageID Message ID. One of 'Abort', 'Success', or 'Failure', or some custom message |
| 776 | - * @return boolean True if successful |
|
| 775 | + * @return boolean|null True if successful |
|
| 777 | 776 | */ |
| 778 | 777 | public function sendMessage($messageID) { |
| 779 | 778 | // Check message, subject, and additional arguments to include |
@@ -922,7 +921,7 @@ discard block |
||
| 922 | 921 | /** |
| 923 | 922 | * Finds the next {@link PipelineStep} that needs to execute. Relies on $this->CurrentStep() being a valid step. |
| 924 | 923 | * |
| 925 | - * @return PipelineStep|null The next step in the pipeline, or null if none remain. |
|
| 924 | + * @return DataObject|null The next step in the pipeline, or null if none remain. |
|
| 926 | 925 | */ |
| 927 | 926 | protected function findNextStep() { |
| 928 | 927 | // otherwise get next step in chain |
@@ -939,7 +938,7 @@ discard block |
||
| 939 | 938 | /** |
| 940 | 939 | * Finds the previous {@link PipelineStep} that executed. Relies on $this->CurrentStep() being a valid step. |
| 941 | 940 | * |
| 942 | - * @return PipelineStep|null The previous step in the pipeline, or null if this is the first. |
|
| 941 | + * @return DataObject|null The previous step in the pipeline, or null if this is the first. |
|
| 943 | 942 | */ |
| 944 | 943 | public function findPreviousStep() { |
| 945 | 944 | // otherwise get previous step in chain |
@@ -1013,6 +1012,9 @@ discard block |
||
| 1013 | 1012 | return $this->getField('DryRun'); |
| 1014 | 1013 | } |
| 1015 | 1014 | |
| 1015 | + /** |
|
| 1016 | + * @param string $action |
|
| 1017 | + */ |
|
| 1016 | 1018 | public function Link($action = null) { |
| 1017 | 1019 | return Controller::join_links($this->Environment()->Link(), 'pipeline', $this->ID, $action); |
| 1018 | 1020 | } |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // Get logs from rollback steps (only for RollbackSteps). |
| 303 | 303 | $rollbackSteps = array($this->RollbackStep1(), $this->RollbackStep2()); |
| 304 | - foreach ($rollbackSteps as $rollback) { |
|
| 305 | - if($rollback->exists() && $rollback->ClassName=='RollbackStep') { |
|
| 304 | + foreach($rollbackSteps as $rollback) { |
|
| 305 | + if($rollback->exists() && $rollback->ClassName == 'RollbackStep') { |
|
| 306 | 306 | if($rollback->RollbackDeploymentID > 0) { |
| 307 | 307 | $logs[] = array( |
| 308 | 308 | 'ButtonText' => 'Rollback Log', |
@@ -598,11 +598,11 @@ discard block |
||
| 598 | 598 | $success = true; |
| 599 | 599 | $rollback1 = $this->RollbackStep1(); |
| 600 | 600 | $rollback2 = $this->RollbackStep2(); |
| 601 | - if (!empty($rollback1) && $rollback1->Status=='Failed') $success = false; |
|
| 602 | - if (!empty($rollback2) && $rollback2->Status=='Failed') $success = false; |
|
| 601 | + if(!empty($rollback1) && $rollback1->Status == 'Failed') $success = false; |
|
| 602 | + if(!empty($rollback2) && $rollback2->Status == 'Failed') $success = false; |
|
| 603 | 603 | |
| 604 | 604 | // Send messages. |
| 605 | - if ($success) { |
|
| 605 | + if($success) { |
|
| 606 | 606 | $this->log("Pipeline failed, but rollback completed successfully."); |
| 607 | 607 | $this->sendMessage(self::ALERT_ROLLBACK_SUCCESS); |
| 608 | 608 | } else { |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | |
| 633 | 633 | // Add smoke test step, if available, for later processing. |
| 634 | 634 | $configRollback2 = $this->getConfigSetting('RollbackStep2'); |
| 635 | - if ($configRollback2) { |
|
| 635 | + if($configRollback2) { |
|
| 636 | 636 | $stepRollback2 = $this->pushPipelineStep('RollbackStep2', $configRollback2); |
| 637 | 637 | $this->RollbackStep2ID = $stepRollback2->ID; |
| 638 | 638 | } |
@@ -648,10 +648,10 @@ discard block |
||
| 648 | 648 | */ |
| 649 | 649 | protected function canStartRollback() { |
| 650 | 650 | // The rollback cannot run twice. |
| 651 | - if ($this->isRollback()) return false; |
|
| 651 | + if($this->isRollback()) return false; |
|
| 652 | 652 | |
| 653 | 653 | // Rollbacks must be configured. |
| 654 | - if (!$this->getConfigSetting('RollbackStep1')) return false; |
|
| 654 | + if(!$this->getConfigSetting('RollbackStep1')) return false; |
|
| 655 | 655 | |
| 656 | 656 | // On dryrun let rollback run |
| 657 | 657 | if($this->DryRun) return true; |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | // Pipeline must have ran a deployment to be able to rollback. |
| 660 | 660 | $deploy = $this->CurrentDeployment(); |
| 661 | 661 | $previous = $this->PreviousDeployment(); |
| 662 | - if (!$deploy->exists() || !$previous->exists()) return false; |
|
| 662 | + if(!$deploy->exists() || !$previous->exists()) return false; |
|
| 663 | 663 | |
| 664 | 664 | return true; |
| 665 | 665 | } |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | // Abort all running or queued steps. |
| 676 | 676 | $steps = $this->Steps(); |
| 677 | 677 | foreach($steps as $step) { |
| 678 | - if ($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 678 | + if($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | if($this->canStartRollback()) { |
| 682 | 682 | $this->beginRollback(); |
| 683 | - } else if ($this->isRollback()) { |
|
| 683 | + } else if($this->isRollback()) { |
|
| 684 | 684 | $this->finaliseRollback(); |
| 685 | 685 | } else { |
| 686 | 686 | // Not able to roll back - fail immediately. |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | // Abort all running or queued steps. |
| 724 | 724 | $steps = $this->Steps(); |
| 725 | 725 | foreach($steps as $step) { |
| 726 | - if ($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 726 | + if($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // Send notification to users about this event |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | */ |
| 739 | 739 | protected function generateMessageTemplate($messageID) { |
| 740 | 740 | $subject = $this->getConfigSetting('PipelineConfig', 'Subjects', $messageID); |
| 741 | - $message = $this->getConfigSetting('PipelineConfig', 'Messages', $messageID); |
|
| 741 | + $message = $this->getConfigSetting('PipelineConfig', 'Messages', $messageID); |
|
| 742 | 742 | $substitutions = $this->getReplacements(); |
| 743 | 743 | return $this->injectMessageReplacements($message, $subject, $substitutions); |
| 744 | 744 | } |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | if(!$nextStep) { |
| 888 | 888 | |
| 889 | 889 | // Special handling, since the main pipeline has already failed at this stage. |
| 890 | - if ($this->isRollback()) { |
|
| 890 | + if($this->isRollback()) { |
|
| 891 | 891 | $this->finaliseRollback(); |
| 892 | 892 | return false; |
| 893 | 893 | } |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | 'PipelineID' => $this->ID, |
| 898 | 898 | 'Status' => 'Failed' |
| 899 | 899 | ))->count(); |
| 900 | - if ($failedSteps) { |
|
| 900 | + if($failedSteps) { |
|
| 901 | 901 | $this->log('At least one of the steps has failed marking the pipeline as failed'); |
| 902 | 902 | $this->markFailed(); |
| 903 | 903 | return false; |
@@ -198,7 +198,9 @@ discard block |
||
| 198 | 198 | public function __isset($property) { |
| 199 | 199 | // Workaround fixed in https://github.com/silverstripe/silverstripe-framework/pull/3201 |
| 200 | 200 | // Remove this once we update to a version of framework which supports this |
| 201 | - if($property === 'MessagingService') return !empty($this->messagingService); |
|
| 201 | + if($property === 'MessagingService') { |
|
| 202 | + return !empty($this->messagingService); |
|
| 203 | + } |
|
| 202 | 204 | return parent::__isset($property); |
| 203 | 205 | } |
| 204 | 206 | |
@@ -234,8 +236,12 @@ discard block |
||
| 234 | 236 | public function canAbort($member = null) { |
| 235 | 237 | // Owner can abort |
| 236 | 238 | $member = $member ?: Member::currentUser(); |
| 237 | - if(!$member) return false; |
|
| 238 | - if($member->ID == $this->AuthorID) return true; |
|
| 239 | + if(!$member) { |
|
| 240 | + return false; |
|
| 241 | + } |
|
| 242 | + if($member->ID == $this->AuthorID) { |
|
| 243 | + return true; |
|
| 244 | + } |
|
| 239 | 245 | |
| 240 | 246 | // Check environment permission |
| 241 | 247 | return $this->Environment()->canAbort($member); |
@@ -263,7 +269,9 @@ discard block |
||
| 263 | 269 | * @return ArrayList List of items with a Link and Title attribute |
| 264 | 270 | */ |
| 265 | 271 | public function RunningOptions() { |
| 266 | - if(!$this->isActive()) return null; |
|
| 272 | + if(!$this->isActive()) { |
|
| 273 | + return null; |
|
| 274 | + } |
|
| 267 | 275 | $actions = array(); |
| 268 | 276 | |
| 269 | 277 | // Let current step update the current list of options |
@@ -279,7 +287,9 @@ discard block |
||
| 279 | 287 | * @return ArrayList List of logs with a Link and Title attribute |
| 280 | 288 | */ |
| 281 | 289 | public function LogOptions() { |
| 282 | - if(!$this->isActive()) return null; |
|
| 290 | + if(!$this->isActive()) { |
|
| 291 | + return null; |
|
| 292 | + } |
|
| 283 | 293 | $logs[] = array( |
| 284 | 294 | 'ButtonText' => 'Pipeline Log', |
| 285 | 295 | 'Link' => $this->Link() |
@@ -374,7 +384,9 @@ discard block |
||
| 374 | 384 | public function getConfigSetting($setting) { |
| 375 | 385 | $source = $this->getConfigData(); |
| 376 | 386 | foreach(func_get_args() as $setting) { |
| 377 | - if(empty($source[$setting])) return null; |
|
| 387 | + if(empty($source[$setting])) { |
|
| 388 | + return null; |
|
| 389 | + } |
|
| 378 | 390 | $source = $source[$setting]; |
| 379 | 391 | } |
| 380 | 392 | return $source; |
@@ -598,8 +610,12 @@ discard block |
||
| 598 | 610 | $success = true; |
| 599 | 611 | $rollback1 = $this->RollbackStep1(); |
| 600 | 612 | $rollback2 = $this->RollbackStep2(); |
| 601 | - if (!empty($rollback1) && $rollback1->Status=='Failed') $success = false; |
|
| 602 | - if (!empty($rollback2) && $rollback2->Status=='Failed') $success = false; |
|
| 613 | + if (!empty($rollback1) && $rollback1->Status=='Failed') { |
|
| 614 | + $success = false; |
|
| 615 | + } |
|
| 616 | + if (!empty($rollback2) && $rollback2->Status=='Failed') { |
|
| 617 | + $success = false; |
|
| 618 | + } |
|
| 603 | 619 | |
| 604 | 620 | // Send messages. |
| 605 | 621 | if ($success) { |
@@ -648,18 +664,26 @@ discard block |
||
| 648 | 664 | */ |
| 649 | 665 | protected function canStartRollback() { |
| 650 | 666 | // The rollback cannot run twice. |
| 651 | - if ($this->isRollback()) return false; |
|
| 667 | + if ($this->isRollback()) { |
|
| 668 | + return false; |
|
| 669 | + } |
|
| 652 | 670 | |
| 653 | 671 | // Rollbacks must be configured. |
| 654 | - if (!$this->getConfigSetting('RollbackStep1')) return false; |
|
| 672 | + if (!$this->getConfigSetting('RollbackStep1')) { |
|
| 673 | + return false; |
|
| 674 | + } |
|
| 655 | 675 | |
| 656 | 676 | // On dryrun let rollback run |
| 657 | - if($this->DryRun) return true; |
|
| 677 | + if($this->DryRun) { |
|
| 678 | + return true; |
|
| 679 | + } |
|
| 658 | 680 | |
| 659 | 681 | // Pipeline must have ran a deployment to be able to rollback. |
| 660 | 682 | $deploy = $this->CurrentDeployment(); |
| 661 | 683 | $previous = $this->PreviousDeployment(); |
| 662 | - if (!$deploy->exists() || !$previous->exists()) return false; |
|
| 684 | + if (!$deploy->exists() || !$previous->exists()) { |
|
| 685 | + return false; |
|
| 686 | + } |
|
| 663 | 687 | |
| 664 | 688 | return true; |
| 665 | 689 | } |
@@ -675,7 +699,9 @@ discard block |
||
| 675 | 699 | // Abort all running or queued steps. |
| 676 | 700 | $steps = $this->Steps(); |
| 677 | 701 | foreach($steps as $step) { |
| 678 | - if ($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 702 | + if ($step->isQueued() || $step->isRunning()) { |
|
| 703 | + $step->abort(); |
|
| 704 | + } |
|
| 679 | 705 | } |
| 680 | 706 | |
| 681 | 707 | if($this->canStartRollback()) { |
@@ -687,7 +713,9 @@ discard block |
||
| 687 | 713 | $this->Status = 'Failed'; |
| 688 | 714 | $this->log("Pipeline failed, not running rollback (not configured or not applicable yet)."); |
| 689 | 715 | $this->write(); |
| 690 | - if($notify) $this->sendMessage(self::ALERT_FAILURE); |
|
| 716 | + if($notify) { |
|
| 717 | + $this->sendMessage(self::ALERT_FAILURE); |
|
| 718 | + } |
|
| 691 | 719 | } |
| 692 | 720 | } |
| 693 | 721 | |
@@ -723,7 +751,9 @@ discard block |
||
| 723 | 751 | // Abort all running or queued steps. |
| 724 | 752 | $steps = $this->Steps(); |
| 725 | 753 | foreach($steps as $step) { |
| 726 | - if ($step->isQueued() || $step->isRunning()) $step->abort(); |
|
| 754 | + if ($step->isQueued() || $step->isRunning()) { |
|
| 755 | + $step->abort(); |
|
| 756 | + } |
|
| 727 | 757 | } |
| 728 | 758 | |
| 729 | 759 | // Send notification to users about this event |
@@ -753,7 +783,9 @@ discard block |
||
| 753 | 783 | */ |
| 754 | 784 | public function injectMessageReplacements($message, $subject, $substitutions) { |
| 755 | 785 | // Handle empty messages |
| 756 | - if(empty($subject) && empty($message)) return array(null, null); |
|
| 786 | + if(empty($subject) && empty($message)) { |
|
| 787 | + return array(null, null); |
|
| 788 | + } |
|
| 757 | 789 | |
| 758 | 790 | // Check if there's a role specific message |
| 759 | 791 | $subjectText = str_replace( |
@@ -977,8 +1009,14 @@ discard block |
||
| 977 | 1009 | $caller = $bt[$index]; |
| 978 | 1010 | $caller['line'] = $bt[($index - 1)]['line']; // Overwrite line and file to be the the line/file that actually |
| 979 | 1011 | $caller['file'] = $bt[($index - 1)]['file']; // called the function, not where the function is defined. |
| 980 | - if(!isset($caller['class'])) $caller['class'] = ''; // In case it wasn't called from a class |
|
| 981 | - if(!isset($caller['type'])) $caller['type'] = ''; // In case it doesn't have a type (wasn't called from class) |
|
| 1012 | + if(!isset($caller['class'])) { |
|
| 1013 | + $caller['class'] = ''; |
|
| 1014 | + } |
|
| 1015 | + // In case it wasn't called from a class |
|
| 1016 | + if(!isset($caller['type'])) { |
|
| 1017 | + $caller['type'] = ''; |
|
| 1018 | + } |
|
| 1019 | + // In case it doesn't have a type (wasn't called from class) |
|
| 982 | 1020 | |
| 983 | 1021 | $log->write(sprintf("[%s::%s() (line %d)] %s", $caller['class'], $caller['function'], $caller['line'], $message)); |
| 984 | 1022 | } |
@@ -1038,7 +1076,9 @@ discard block |
||
| 1038 | 1076 | public function LogContent() { |
| 1039 | 1077 | if($this->exists() && $this->Environment()) { |
| 1040 | 1078 | $logger = $this->getLogger(); |
| 1041 | - if($logger->exists()) return $logger->content(); |
|
| 1079 | + if($logger->exists()) { |
|
| 1080 | + return $logger->content(); |
|
| 1081 | + } |
|
| 1042 | 1082 | } |
| 1043 | 1083 | } |
| 1044 | 1084 | |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | */ |
| 283 | 283 | public function startApproval() { |
| 284 | 284 | $this->Status = 'Started'; |
| 285 | - $this->log("Starting {$this->Title}..."); |
|
| 285 | + $this->log("starting {$this->Title}..."); |
|
| 286 | 286 | // Determine if we should use delayed notification |
| 287 | 287 | $recipientGroup = 'all'; |
| 288 | 288 | if($this->getConfigSetting('RecipientsDelay')) { |
@@ -319,7 +319,7 @@ |
||
| 319 | 319 | * @param string $messageID Message ID. One of 'Reject', 'Approve', 'TimeOut' or 'Request' |
| 320 | 320 | * @param mixed $recipientGroup Either a numeric index of the next recipient to send to, or "all" for all |
| 321 | 321 | * This is used for delayed notification so that failover recipients can be notified. |
| 322 | - * @return boolean True if successful |
|
| 322 | + * @return boolean|null True if successful |
|
| 323 | 323 | */ |
| 324 | 324 | protected function sendMessage($messageID, $recipientGroup = 'all') { |
| 325 | 325 | // Add additionally configured arguments |
@@ -179,7 +179,9 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Skip subsequent approvals if already approved / rejected |
| 182 | - if($this->hasResponse()) return; |
|
| 182 | + if($this->hasResponse()) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 183 | 185 | |
| 184 | 186 | // Approve |
| 185 | 187 | $this->Approval = 'Approved'; |
@@ -205,7 +207,9 @@ discard block |
||
| 205 | 207 | } |
| 206 | 208 | |
| 207 | 209 | // Skip subsequent approvals if already approved / rejected |
| 208 | - if($this->hasResponse()) return; |
|
| 210 | + if($this->hasResponse()) { |
|
| 211 | + return; |
|
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | // Reject |
| 211 | 215 | $this->Approval = 'Rejected'; |
@@ -363,7 +367,9 @@ discard block |
||
| 363 | 367 | public function getRunningDescription() { |
| 364 | 368 | |
| 365 | 369 | // Don't show options if this step has already been confirmed |
| 366 | - if($this->hasResponse() || !$this->isRunning()) return; |
|
| 370 | + if($this->hasResponse() || !$this->isRunning()) { |
|
| 371 | + return; |
|
| 372 | + } |
|
| 367 | 373 | |
| 368 | 374 | return 'This deployment is currently awaiting approval before it can complete.'; |
| 369 | 375 | } |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Will convert the Filename to the version 1.2 of deploynaut where it |
|
| 4 | - * more or less is exactly is the same as the Name but with .rb |
|
| 5 | - */ |
|
| 3 | + * Will convert the Filename to the version 1.2 of deploynaut where it |
|
| 4 | + * more or less is exactly is the same as the Name but with .rb |
|
| 5 | + */ |
|
| 6 | 6 | class DNMigrate1_1to1_2 extends BuildTask { |
| 7 | 7 | /** |
| 8 | 8 | * @param SS_HTTPRequest $request |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | foreach($environments as $environment) { |
| 15 | 15 | $newFilename = basename($environment->Filename); |
| 16 | 16 | if($environment->Filename != $newFilename) { |
| 17 | - echo 'Migrating "'.$environment->Filename.'" to '.$newFilename.PHP_EOL; |
|
| 17 | + echo 'Migrating "' . $environment->Filename . '" to ' . $newFilename . PHP_EOL; |
|
| 18 | 18 | $environment->Filename = $newFilename; |
| 19 | 19 | $environment->write(); |
| 20 | 20 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | foreach($projects as $project) { |
| 27 | 27 | if(!$project->projectFolderExists()) { |
| 28 | 28 | $warnings = true; |
| 29 | - echo 'Project '.$project->Name.' don\'t have a cap project folder'.PHP_EOL; |
|
| 29 | + echo 'Project ' . $project->Name . ' don\'t have a cap project folder' . PHP_EOL; |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | if($warnings) { |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Surface Filesystem::sync() as a dev task in case CMS has not been included. |
|
| 4 | - */ |
|
| 3 | + * Surface Filesystem::sync() as a dev task in case CMS has not been included. |
|
| 4 | + */ |
|
| 5 | 5 | class CMSFilesystemSyncTask extends BuildTask { |
| 6 | 6 | public function run($request = null) { |
| 7 | 7 | Filesystem::sync(); |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | */ |
| 283 | 283 | public function startApproval() { |
| 284 | 284 | $this->Status = 'Started'; |
| 285 | - $this->log("Starting {$this->Title}..."); |
|
| 285 | + $this->log("starting {$this->Title}..."); |
|
| 286 | 286 | // Determine if we should use delayed notification |
| 287 | 287 | $recipientGroup = 'all'; |
| 288 | 288 | if($this->getConfigSetting('RecipientsDelay')) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | curl_setopt($ch, CURLOPT_URL, $test['URL']); |
| 126 | 126 | |
| 127 | 127 | // Allow individual tests to override number of attempts |
| 128 | - $attempts = (int) $this->getConfigSetting('Attempts'); |
|
| 128 | + $attempts = (int)$this->getConfigSetting('Attempts'); |
|
| 129 | 129 | if(!empty($test['Attempts'])) $attempts = $test['Attempts']; |
| 130 | 130 | |
| 131 | 131 | // Run through each attempt |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Check response |
| 149 | - $info = curl_getinfo($ch); |
|
| 149 | + $info = curl_getinfo($ch); |
|
| 150 | 150 | |
| 151 | 151 | // if an expected response time is specified, check that against the results |
| 152 | 152 | if(isset($test['ExpectResponse'])) { |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | } elseif(!$tests && $defaultTests) { |
| 75 | 75 | $tests = $defaultTests; |
| 76 | 76 | } |
| 77 | - if($tests) return $tests; |
|
| 77 | + if($tests) { |
|
| 78 | + return $tests; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | // if there's no tests to check for, fallback to trying to find the |
| 80 | 82 | // site's homepage by looking at the DNEnvironment fields. |
@@ -126,7 +128,9 @@ discard block |
||
| 126 | 128 | |
| 127 | 129 | // Allow individual tests to override number of attempts |
| 128 | 130 | $attempts = (int) $this->getConfigSetting('Attempts'); |
| 129 | - if(!empty($test['Attempts'])) $attempts = $test['Attempts']; |
|
| 131 | + if(!empty($test['Attempts'])) { |
|
| 132 | + $attempts = $test['Attempts']; |
|
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | // Run through each attempt |
| 132 | 136 | for($i = 0; $i < $attempts; $i++) { |
@@ -189,7 +193,9 @@ discard block |
||
| 189 | 193 | } |
| 190 | 194 | |
| 191 | 195 | // Run out of re-attempts |
| 192 | - if($attempts > 1) $this->log("Failed after {$attempts} attempts"); |
|
| 196 | + if($attempts > 1) { |
|
| 197 | + $this->log("Failed after {$attempts} attempts"); |
|
| 198 | + } |
|
| 193 | 199 | return false; |
| 194 | 200 | } |
| 195 | 201 | |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | */ |
| 283 | 283 | public function startApproval() { |
| 284 | 284 | $this->Status = 'Started'; |
| 285 | - $this->log("Starting {$this->Title}..."); |
|
| 285 | + $this->log("starting {$this->Title}..."); |
|
| 286 | 286 | // Determine if we should use delayed notification |
| 287 | 287 | $recipientGroup = 'all'; |
| 288 | 288 | if($this->getConfigSetting('RecipientsDelay')) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // check if we have timed out |
| 42 | - if ($this->isTimedOut()) { |
|
| 42 | + if($this->isTimedOut()) { |
|
| 43 | 43 | $this->log(sprintf(_t('TriggerDeployStep.DEPLOYTIMEOUT', |
| 44 | 44 | 'Deployment step is older then %s seconds and has timed out'), |
| 45 | 45 | $this->MaxDuration)); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ($this->Status == 'Queued') { |
|
| 89 | + if($this->Status == 'Queued') { |
|
| 90 | 90 | $this->start(); |
| 91 | 91 | } |
| 92 | 92 | // Trigger deployment |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function StartDeployment() { |
| 105 | 105 | $this->Status = 'Started'; |
| 106 | - if (!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
| 106 | + if(!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
| 107 | 107 | $this->log("Starting {$this->Title}..."); |
| 108 | 108 | $this->write(); |
| 109 | 109 | return true; |
@@ -103,7 +103,9 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function StartDeployment() { |
| 105 | 105 | $this->Status = 'Started'; |
| 106 | - if (!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
| 106 | + if (!$this->Started) { |
|
| 107 | + $this->Started = SS_Datetime::now()->Rfc2822(); |
|
| 108 | + } |
|
| 107 | 109 | $this->log("Starting {$this->Title}..."); |
| 108 | 110 | $this->write(); |
| 109 | 111 | return true; |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | |
| 112 | 114 | public function getRunningDescription() { |
| 113 | 115 | // Don't show options if this step has already been confirmed |
| 114 | - if($this->Deployed) return; |
|
| 116 | + if($this->Deployed) { |
|
| 117 | + return; |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | return _t('TriggerDeployStep.RUNNINGDESCRIPTION', |
| 117 | 121 | 'Please press the "Deploy" button to continue deployment'); |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * |
| 43 | 43 | * @param SS_HTTPRequest $request |
| 44 | - * @return string |
|
| 44 | + * @return SS_HTTPResponse |
|
| 45 | 45 | */ |
| 46 | 46 | public function listProjects(SS_HTTPRequest $request) { |
| 47 | 47 | $response = array( |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | 'projects' => array(), |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if($request->httpMethod() != 'GET') return $this->message('API not found', 404);; |
|
| 52 | + if($request->httpMethod() != 'GET') return $this->message('API not found', 404); ; |
|
| 53 | 53 | |
| 54 | 54 | foreach(DNProject::get() as $item) { |
| 55 | 55 | if($item->canView($this->getMember())) { |
@@ -49,7 +49,10 @@ |
||
| 49 | 49 | 'projects' => array(), |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if($request->httpMethod() != 'GET') return $this->message('API not found', 404);; |
|
| 52 | + if($request->httpMethod() != 'GET') { |
|
| 53 | + return $this->message('API not found', 404); |
|
| 54 | + } |
|
| 55 | + ; |
|
| 53 | 56 | |
| 54 | 57 | foreach(DNProject::get() as $item) { |
| 55 | 58 | if($item->canView($this->getMember())) { |