@@ -79,6 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | + * @param string $code |
|
| 82 | 83 | */ |
| 83 | 84 | public function setActionCode($code) |
| 84 | 85 | { |
@@ -95,6 +96,7 @@ discard block |
||
| 95 | 96 | |
| 96 | 97 | /** |
| 97 | 98 | * @param int |
| 99 | + * @param string $seconds |
|
| 98 | 100 | */ |
| 99 | 101 | public function setEstimatedTime($seconds) |
| 100 | 102 | { |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | public function getChangesModificationNeeded() |
| 142 | 142 | { |
| 143 | 143 | $filtered = []; |
| 144 | - foreach ($this->changes as $change => $details) { |
|
| 145 | - if (array_key_exists('description', $details)) { |
|
| 144 | + foreach($this->changes as $change => $details) { |
|
| 145 | + if(array_key_exists('description', $details)) { |
|
| 146 | 146 | $filtered[$change] = $details; |
| 147 | - } elseif ( |
|
| 147 | + } elseif( |
|
| 148 | 148 | (array_key_exists('from', $details) || array_key_exists('to', $details)) |
| 149 | 149 | && $details['from'] !== $details['to'] |
| 150 | 150 | ) { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | public function getChange($key) |
| 178 | 178 | { |
| 179 | 179 | $changes = $this->getChanges(); |
| 180 | - if (array_key_exists($key, $changes)) { |
|
| 180 | + if(array_key_exists($key, $changes)) { |
|
| 181 | 181 | return new ArrayData($changes[$key]); |
| 182 | 182 | } |
| 183 | 183 | return null; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function getOption($option) |
| 200 | 200 | { |
| 201 | - if (!empty($this->options[$option])) { |
|
| 201 | + if(!empty($this->options[$option])) { |
|
| 202 | 202 | return $this->options[$option]; |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | DeploymentStrategy::WARNING_CODE => 1, |
| 244 | 244 | DeploymentStrategy::ERROR_CODE => 2 |
| 245 | 245 | ]; |
| 246 | - if ($map[$current] < $map[$code]) { |
|
| 246 | + if($map[$current] < $map[$code]) { |
|
| 247 | 247 | $this->setValidationCode($code); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | 276 | $output = array(); |
| 277 | - foreach ($fields as $field) { |
|
| 277 | + foreach($fields as $field) { |
|
| 278 | 278 | $output[$field] = $this->$field; |
| 279 | 279 | } |
| 280 | 280 | return $output; |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | 'messages' |
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | - foreach ($fields as $field) { |
|
| 322 | - if (!empty($data[$field])) { |
|
| 321 | + foreach($fields as $field) { |
|
| 322 | + if(!empty($data[$field])) { |
|
| 323 | 323 | $this->$field = $data[$field]; |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | * @param array $data |
| 998 | 998 | * @param Form $form |
| 999 | 999 | * |
| 1000 | - * @return bool|HTMLText|SS_HTTPResponse |
|
| 1000 | + * @return SS_HTTPResponse|null |
|
| 1001 | 1001 | */ |
| 1002 | 1002 | public function doCreateEnvironment($data, Form $form) |
| 1003 | 1003 | { |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | /** |
| 2431 | 2431 | * Create project action. |
| 2432 | 2432 | * |
| 2433 | - * @return SS_HTTPResponse |
|
| 2433 | + * @return HTMLText |
|
| 2434 | 2434 | */ |
| 2435 | 2435 | public function createproject(SS_HTTPRequest $request) |
| 2436 | 2436 | { |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | Requirements::javascript('deploynaut/javascript/material.js'); |
| 192 | 192 | |
| 193 | 193 | // Load the buildable dependencies only if not loaded centrally. |
| 194 | - if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { |
|
| 195 | - if (\Director::isDev()) { |
|
| 194 | + if(!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { |
|
| 195 | + if(\Director::isDev()) { |
|
| 196 | 196 | \Requirements::javascript('deploynaut/static/bundle-debug.js'); |
| 197 | 197 | } else { |
| 198 | 198 | \Requirements::javascript('deploynaut/static/bundle.js'); |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public static function FlagSnapshotsEnabled() |
| 213 | 213 | { |
| 214 | - if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
| 214 | + if(defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | - if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 217 | + if(defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 218 | 218 | $allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS); |
| 219 | 219 | $member = Member::currentUser(); |
| 220 | - if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
| 220 | + if($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
| 221 | 221 | return true; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | public static function get_support_links() |
| 231 | 231 | { |
| 232 | 232 | $supportLinks = self::config()->support_links; |
| 233 | - if ($supportLinks) { |
|
| 233 | + if($supportLinks) { |
|
| 234 | 234 | return new ArrayList($supportLinks); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | parent::init(); |
| 256 | 256 | |
| 257 | - if (!Member::currentUser() && !Session::get('AutoLoginHash')) { |
|
| 257 | + if(!Member::currentUser() && !Session::get('AutoLoginHash')) { |
|
| 258 | 258 | return Security::permissionFailure(); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -341,11 +341,11 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | // Performs canView permission check by limiting visible projects |
| 343 | 343 | $project = $this->getCurrentProject(); |
| 344 | - if (!$project) { |
|
| 344 | + if(!$project) { |
|
| 345 | 345 | return $this->project404Response(); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if (!$project->canBackup()) { |
|
| 348 | + if(!$project->canBackup()) { |
|
| 349 | 349 | return new SS_HTTPResponse("Not allowed to create snapshots on any environments", 401); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -368,11 +368,11 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | // Performs canView permission check by limiting visible projects |
| 370 | 370 | $project = $this->getCurrentProject(); |
| 371 | - if (!$project) { |
|
| 371 | + if(!$project) { |
|
| 372 | 372 | return $this->project404Response(); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if (!$project->canUploadArchive()) { |
|
| 375 | + if(!$project->canUploadArchive()) { |
|
| 376 | 376 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -405,22 +405,22 @@ discard block |
||
| 405 | 405 | { |
| 406 | 406 | // Performs canView permission check by limiting visible projects |
| 407 | 407 | $project = $this->getCurrentProject(); |
| 408 | - if (!$project) { |
|
| 408 | + if(!$project) { |
|
| 409 | 409 | return $this->project404Response(); |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if (!$project->canUploadArchive()) { |
|
| 412 | + if(!$project->canUploadArchive()) { |
|
| 413 | 413 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Framing an environment as a "group of people with download access" |
| 417 | 417 | // makes more sense to the user here, while still allowing us to enforce |
| 418 | 418 | // environment specific restrictions on downloading the file later on. |
| 419 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 419 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 420 | 420 | return $item->canUploadArchive(); |
| 421 | 421 | }); |
| 422 | 422 | $envsMap = array(); |
| 423 | - foreach ($envs as $env) { |
|
| 423 | + foreach($envs as $env) { |
|
| 424 | 424 | $envsMap[$env->ID] = $env->Name; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -465,18 +465,18 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | // Performs canView permission check by limiting visible projects |
| 467 | 467 | $project = $this->getCurrentProject(); |
| 468 | - if (!$project) { |
|
| 468 | + if(!$project) { |
|
| 469 | 469 | return $this->project404Response(); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | $validEnvs = $project->DNEnvironmentList() |
| 473 | - ->filterByCallback(function ($item) { |
|
| 473 | + ->filterByCallback(function($item) { |
|
| 474 | 474 | return $item->canUploadArchive(); |
| 475 | 475 | }); |
| 476 | 476 | |
| 477 | 477 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 478 | 478 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 479 | - if (!$environment) { |
|
| 479 | + if(!$environment) { |
|
| 480 | 480 | throw new LogicException('Invalid environment'); |
| 481 | 481 | } |
| 482 | 482 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $dataArchive->write(); |
| 502 | 502 | $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
| 503 | 503 | |
| 504 | - $cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) { |
|
| 504 | + $cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) { |
|
| 505 | 505 | $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
| 506 | 506 | $process->run(); |
| 507 | 507 | $dataTransfer->delete(); |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | // extract the sspak contents so we can inspect them |
| 512 | 512 | try { |
| 513 | 513 | $dataArchive->extractArchive($workingDir); |
| 514 | - } catch (Exception $e) { |
|
| 514 | + } catch(Exception $e) { |
|
| 515 | 515 | $cleanupFn(); |
| 516 | 516 | $form->sessionMessage( |
| 517 | 517 | 'There was a problem trying to open your snapshot for processing. Please try uploading again', |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | // validate that the sspak contents match the declared contents |
| 524 | 524 | $result = $dataArchive->validateArchiveContents(); |
| 525 | - if (!$result->valid()) { |
|
| 525 | + if(!$result->valid()) { |
|
| 526 | 526 | $cleanupFn(); |
| 527 | 527 | $form->sessionMessage($result->message(), 'bad'); |
| 528 | 528 | return $this->redirectBack(); |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | try { |
| 533 | 533 | $dataArchive->fixArchivePermissions($workingDir); |
| 534 | 534 | $dataArchive->setArchiveFromFiles($workingDir); |
| 535 | - } catch (Exception $e) { |
|
| 535 | + } catch(Exception $e) { |
|
| 536 | 536 | $cleanupFn(); |
| 537 | 537 | $form->sessionMessage( |
| 538 | 538 | 'There was a problem processing your snapshot. Please try uploading again', |
@@ -563,22 +563,22 @@ discard block |
||
| 563 | 563 | { |
| 564 | 564 | // Performs canView permission check by limiting visible projects |
| 565 | 565 | $project = $this->getCurrentProject(); |
| 566 | - if (!$project) { |
|
| 566 | + if(!$project) { |
|
| 567 | 567 | return $this->project404Response(); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - if (!$project->canUploadArchive()) { |
|
| 570 | + if(!$project->canUploadArchive()) { |
|
| 571 | 571 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // Framing an environment as a "group of people with download access" |
| 575 | 575 | // makes more sense to the user here, while still allowing us to enforce |
| 576 | 576 | // environment specific restrictions on downloading the file later on. |
| 577 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 577 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 578 | 578 | return $item->canUploadArchive(); |
| 579 | 579 | }); |
| 580 | 580 | $envsMap = array(); |
| 581 | - foreach ($envs as $env) { |
|
| 581 | + foreach($envs as $env) { |
|
| 582 | 582 | $envsMap[$env->ID] = $env->Name; |
| 583 | 583 | } |
| 584 | 584 | |
@@ -616,17 +616,17 @@ discard block |
||
| 616 | 616 | $this->setCurrentActionType(self::ACTION_SNAPSHOT); |
| 617 | 617 | |
| 618 | 618 | $project = $this->getCurrentProject(); |
| 619 | - if (!$project) { |
|
| 619 | + if(!$project) { |
|
| 620 | 620 | return $this->project404Response(); |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 623 | + $validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 624 | 624 | return $item->canUploadArchive(); |
| 625 | 625 | }); |
| 626 | 626 | |
| 627 | 627 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 628 | 628 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 629 | - if (!$environment) { |
|
| 629 | + if(!$environment) { |
|
| 630 | 630 | throw new LogicException('Invalid environment'); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -666,20 +666,20 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | // Performs canView permission check by limiting visible projects |
| 668 | 668 | $project = $this->getCurrentProject(); |
| 669 | - if (!$project) { |
|
| 669 | + if(!$project) { |
|
| 670 | 670 | return $this->project404Response(); |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if (!$project->canUploadArchive()) { |
|
| 673 | + if(!$project->canUploadArchive()) { |
|
| 674 | 674 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 678 | - if (!$dataArchive) { |
|
| 678 | + if(!$dataArchive) { |
|
| 679 | 679 | return new SS_HTTPResponse("Archive not found.", 404); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if (!$dataArchive->canRestore()) { |
|
| 682 | + if(!$dataArchive->canRestore()) { |
|
| 683 | 683 | throw new SS_HTTPResponse_Exception('Not allowed to restore archive', 403); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -710,19 +710,19 @@ discard block |
||
| 710 | 710 | public function toggleprojectstar(SS_HTTPRequest $request) |
| 711 | 711 | { |
| 712 | 712 | $project = $this->getCurrentProject(); |
| 713 | - if (!$project) { |
|
| 713 | + if(!$project) { |
|
| 714 | 714 | return $this->project404Response(); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | $member = Member::currentUser(); |
| 718 | - if ($member === null) { |
|
| 718 | + if($member === null) { |
|
| 719 | 719 | return $this->project404Response(); |
| 720 | 720 | } |
| 721 | 721 | $favProject = $member->StarredProjects() |
| 722 | 722 | ->filter('DNProjectID', $project->ID) |
| 723 | 723 | ->first(); |
| 724 | 724 | |
| 725 | - if ($favProject) { |
|
| 725 | + if($favProject) { |
|
| 726 | 726 | $member->StarredProjects()->remove($favProject); |
| 727 | 727 | } else { |
| 728 | 728 | $member->StarredProjects()->add($project); |
@@ -737,13 +737,13 @@ discard block |
||
| 737 | 737 | public function branch(SS_HTTPRequest $request) |
| 738 | 738 | { |
| 739 | 739 | $project = $this->getCurrentProject(); |
| 740 | - if (!$project) { |
|
| 740 | + if(!$project) { |
|
| 741 | 741 | return $this->project404Response(); |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | $branchName = $request->getVar('name'); |
| 745 | 745 | $branch = $project->DNBranchList()->byName($branchName); |
| 746 | - if (!$branch) { |
|
| 746 | + if(!$branch) { |
|
| 747 | 747 | return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404); |
| 748 | 748 | } |
| 749 | 749 | |
@@ -760,13 +760,13 @@ discard block |
||
| 760 | 760 | { |
| 761 | 761 | // Performs canView permission check by limiting visible projects |
| 762 | 762 | $project = $this->getCurrentProject(); |
| 763 | - if (!$project) { |
|
| 763 | + if(!$project) { |
|
| 764 | 764 | return $this->project404Response(); |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | // Performs canView permission check by limiting visible projects |
| 768 | 768 | $env = $this->getCurrentEnvironment($project); |
| 769 | - if (!$env) { |
|
| 769 | + if(!$env) { |
|
| 770 | 770 | return $this->environment404Response(); |
| 771 | 771 | } |
| 772 | 772 | |
@@ -816,17 +816,17 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | // Performs canView permission check by limiting visible projects |
| 818 | 818 | $project = $this->getCurrentProject(); |
| 819 | - if (!$project) { |
|
| 819 | + if(!$project) { |
|
| 820 | 820 | return $this->project404Response(); |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | // Performs canView permission check by limiting visible projects |
| 824 | 824 | $environment = $this->getCurrentEnvironment($project); |
| 825 | - if (!$environment) { |
|
| 825 | + if(!$environment) { |
|
| 826 | 826 | return $this->environment404Response(); |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - if (!$environment->DryRunEnabled && $isDryRun) { |
|
| 829 | + if(!$environment->DryRunEnabled && $isDryRun) { |
|
| 830 | 830 | return new SS_HTTPResponse("Dry-run for pipelines is not enabled for this environment", 404); |
| 831 | 831 | } |
| 832 | 832 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | $pipeline->AuthorID = Member::currentUserID(); |
| 839 | 839 | $pipeline->SHA = $sha->FullName(); |
| 840 | 840 | // Record build at time of execution |
| 841 | - if ($currentBuild = $environment->CurrentBuild()) { |
|
| 841 | + if($currentBuild = $environment->CurrentBuild()) { |
|
| 842 | 842 | $pipeline->PreviousDeploymentID = $currentBuild->ID; |
| 843 | 843 | } |
| 844 | 844 | $pipeline->start(); // start() will call write(), so no need to do it here as well. |
@@ -856,20 +856,20 @@ discard block |
||
| 856 | 856 | $params = $request->params(); |
| 857 | 857 | $pipeline = Pipeline::get()->byID($params['Identifier']); |
| 858 | 858 | |
| 859 | - if (!$pipeline || !$pipeline->ID || !$pipeline->Environment()) { |
|
| 859 | + if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) { |
|
| 860 | 860 | throw new SS_HTTPResponse_Exception('Pipeline not found', 404); |
| 861 | 861 | } |
| 862 | - if (!$pipeline->Environment()->canView()) { |
|
| 862 | + if(!$pipeline->Environment()->canView()) { |
|
| 863 | 863 | return Security::permissionFailure(); |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | $environment = $pipeline->Environment(); |
| 867 | 867 | $project = $pipeline->Environment()->Project(); |
| 868 | 868 | |
| 869 | - if ($environment->Name != $params['Environment']) { |
|
| 869 | + if($environment->Name != $params['Environment']) { |
|
| 870 | 870 | throw new LogicException("Environment in URL doesn't match this pipeline"); |
| 871 | 871 | } |
| 872 | - if ($project->Name != $params['Project']) { |
|
| 872 | + if($project->Name != $params['Project']) { |
|
| 873 | 873 | throw new LogicException("Project in URL doesn't match this pipeline"); |
| 874 | 874 | } |
| 875 | 875 | |
@@ -886,22 +886,22 @@ discard block |
||
| 886 | 886 | public function createenv(SS_HTTPRequest $request) |
| 887 | 887 | { |
| 888 | 888 | $params = $request->params(); |
| 889 | - if ($params['Identifier']) { |
|
| 889 | + if($params['Identifier']) { |
|
| 890 | 890 | $record = DNCreateEnvironment::get()->byId($params['Identifier']); |
| 891 | 891 | |
| 892 | - if (!$record || !$record->ID) { |
|
| 892 | + if(!$record || !$record->ID) { |
|
| 893 | 893 | throw new SS_HTTPResponse_Exception('Create environment not found', 404); |
| 894 | 894 | } |
| 895 | - if (!$record->canView()) { |
|
| 895 | + if(!$record->canView()) { |
|
| 896 | 896 | return Security::permissionFailure(); |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | $project = $this->getCurrentProject(); |
| 900 | - if (!$project) { |
|
| 900 | + if(!$project) { |
|
| 901 | 901 | return $this->project404Response(); |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if ($project->Name != $params['Project']) { |
|
| 904 | + if($project->Name != $params['Project']) { |
|
| 905 | 905 | throw new LogicException("Project in URL doesn't match this creation"); |
| 906 | 906 | } |
| 907 | 907 | |
@@ -920,21 +920,21 @@ discard block |
||
| 920 | 920 | $params = $request->params(); |
| 921 | 921 | $env = DNCreateEnvironment::get()->byId($params['Identifier']); |
| 922 | 922 | |
| 923 | - if (!$env || !$env->ID) { |
|
| 923 | + if(!$env || !$env->ID) { |
|
| 924 | 924 | throw new SS_HTTPResponse_Exception('Log not found', 404); |
| 925 | 925 | } |
| 926 | - if (!$env->canView()) { |
|
| 926 | + if(!$env->canView()) { |
|
| 927 | 927 | return Security::permissionFailure(); |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | $project = $env->Project(); |
| 931 | 931 | |
| 932 | - if ($project->Name != $params['Project']) { |
|
| 932 | + if($project->Name != $params['Project']) { |
|
| 933 | 933 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | $log = $env->log(); |
| 937 | - if ($log->exists()) { |
|
| 937 | + if($log->exists()) { |
|
| 938 | 938 | $content = $log->content(); |
| 939 | 939 | } else { |
| 940 | 940 | $content = 'Waiting for action to start'; |
@@ -952,27 +952,27 @@ discard block |
||
| 952 | 952 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS); |
| 953 | 953 | |
| 954 | 954 | $project = $this->getCurrentProject(); |
| 955 | - if (!$project) { |
|
| 955 | + if(!$project) { |
|
| 956 | 956 | return $this->project404Response(); |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | $envType = $project->AllowedEnvironmentType; |
| 960 | - if (!$envType || !class_exists($envType)) { |
|
| 960 | + if(!$envType || !class_exists($envType)) { |
|
| 961 | 961 | return null; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | $backend = Injector::inst()->get($envType); |
| 965 | - if (!($backend instanceof EnvironmentCreateBackend)) { |
|
| 965 | + if(!($backend instanceof EnvironmentCreateBackend)) { |
|
| 966 | 966 | // Only allow this for supported backends. |
| 967 | 967 | return null; |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | $fields = $backend->getCreateEnvironmentFields($project); |
| 971 | - if (!$fields) { |
|
| 971 | + if(!$fields) { |
|
| 972 | 972 | return null; |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - if (!$project->canCreateEnvironments()) { |
|
| 975 | + if(!$project->canCreateEnvironments()) { |
|
| 976 | 976 | return new SS_HTTPResponse('Not allowed to create environments for this project', 401); |
| 977 | 977 | } |
| 978 | 978 | |
@@ -1004,11 +1004,11 @@ discard block |
||
| 1004 | 1004 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS); |
| 1005 | 1005 | |
| 1006 | 1006 | $project = $this->getCurrentProject(); |
| 1007 | - if (!$project) { |
|
| 1007 | + if(!$project) { |
|
| 1008 | 1008 | return $this->project404Response(); |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - if (!$project->canCreateEnvironments()) { |
|
| 1011 | + if(!$project->canCreateEnvironments()) { |
|
| 1012 | 1012 | return new SS_HTTPResponse('Not allowed to create environments for this project', 401); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
@@ -1034,13 +1034,13 @@ discard block |
||
| 1034 | 1034 | { |
| 1035 | 1035 | // Performs canView permission check by limiting visible projects |
| 1036 | 1036 | $project = $this->getCurrentProject(); |
| 1037 | - if (!$project) { |
|
| 1037 | + if(!$project) { |
|
| 1038 | 1038 | return $this->project404Response(); |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | // Performs canView permission check by limiting visible projects |
| 1042 | 1042 | $env = $this->getCurrentEnvironment($project); |
| 1043 | - if (!$env) { |
|
| 1043 | + if(!$env) { |
|
| 1044 | 1044 | return $this->environment404Response(); |
| 1045 | 1045 | } |
| 1046 | 1046 | |
@@ -1065,11 +1065,11 @@ discard block |
||
| 1065 | 1065 | public function DNProjectList() |
| 1066 | 1066 | { |
| 1067 | 1067 | $memberId = Member::currentUserID(); |
| 1068 | - if (!$memberId) { |
|
| 1068 | + if(!$memberId) { |
|
| 1069 | 1069 | return new ArrayList(); |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | - if (Permission::check('ADMIN')) { |
|
| 1072 | + if(Permission::check('ADMIN')) { |
|
| 1073 | 1073 | return DNProject::get(); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | public function getPlatformSpecificStrings() |
| 1085 | 1085 | { |
| 1086 | 1086 | $strings = $this->config()->platform_specific_strings; |
| 1087 | - if ($strings) { |
|
| 1087 | + if($strings) { |
|
| 1088 | 1088 | return new ArrayList($strings); |
| 1089 | 1089 | } |
| 1090 | 1090 | } |
@@ -1097,15 +1097,15 @@ discard block |
||
| 1097 | 1097 | public function getStarredProjects() |
| 1098 | 1098 | { |
| 1099 | 1099 | $member = Member::currentUser(); |
| 1100 | - if ($member === null) { |
|
| 1100 | + if($member === null) { |
|
| 1101 | 1101 | return new ArrayList(); |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | $favProjects = $member->StarredProjects(); |
| 1105 | 1105 | |
| 1106 | 1106 | $list = new ArrayList(); |
| 1107 | - foreach ($favProjects as $project) { |
|
| 1108 | - if ($project->canView($member)) { |
|
| 1107 | + foreach($favProjects as $project) { |
|
| 1108 | + if($project->canView($member)) { |
|
| 1109 | 1109 | $list->add($project); |
| 1110 | 1110 | } |
| 1111 | 1111 | } |
@@ -1126,24 +1126,24 @@ discard block |
||
| 1126 | 1126 | $currentProject = $this->getCurrentProject(); |
| 1127 | 1127 | |
| 1128 | 1128 | $projects = $this->getStarredProjects(); |
| 1129 | - if ($projects->count() < 1) { |
|
| 1129 | + if($projects->count() < 1) { |
|
| 1130 | 1130 | $projects = $this->DNProjectList(); |
| 1131 | 1131 | } else { |
| 1132 | 1132 | $limit = -1; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - if ($projects->count() > 0) { |
|
| 1135 | + if($projects->count() > 0) { |
|
| 1136 | 1136 | $activeProject = false; |
| 1137 | 1137 | |
| 1138 | - if ($limit > 0) { |
|
| 1138 | + if($limit > 0) { |
|
| 1139 | 1139 | $limitedProjects = $projects->limit($limit); |
| 1140 | 1140 | } else { |
| 1141 | 1141 | $limitedProjects = $projects; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - foreach ($limitedProjects as $project) { |
|
| 1144 | + foreach($limitedProjects as $project) { |
|
| 1145 | 1145 | $isActive = $currentProject && $currentProject->ID == $project->ID; |
| 1146 | - if ($isActive) { |
|
| 1146 | + if($isActive) { |
|
| 1147 | 1147 | $activeProject = true; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
@@ -1154,12 +1154,12 @@ discard block |
||
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | // Ensure the current project is in the list |
| 1157 | - if (!$activeProject && $currentProject) { |
|
| 1157 | + if(!$activeProject && $currentProject) { |
|
| 1158 | 1158 | $navigation->unshift(array( |
| 1159 | 1159 | 'Project' => $currentProject, |
| 1160 | 1160 | 'IsActive' => true, |
| 1161 | 1161 | )); |
| 1162 | - if ($limit > 0 && $navigation->count() > $limit) { |
|
| 1162 | + if($limit > 0 && $navigation->count() > $limit) { |
|
| 1163 | 1163 | $navigation->pop(); |
| 1164 | 1164 | } |
| 1165 | 1165 | } |
@@ -1178,17 +1178,17 @@ discard block |
||
| 1178 | 1178 | |
| 1179 | 1179 | // Performs canView permission check by limiting visible projects |
| 1180 | 1180 | $project = $this->getCurrentProject(); |
| 1181 | - if (!$project) { |
|
| 1181 | + if(!$project) { |
|
| 1182 | 1182 | return $this->project404Response(); |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | // Performs canView permission check by limiting visible projects |
| 1186 | 1186 | $environment = $this->getCurrentEnvironment($project); |
| 1187 | - if (!$environment) { |
|
| 1187 | + if(!$environment) { |
|
| 1188 | 1188 | return $this->environment404Response(); |
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | - if (!$environment->canDeploy()) { |
|
| 1191 | + if(!$environment->canDeploy()) { |
|
| 1192 | 1192 | return new SS_HTTPResponse("Not allowed to deploy", 401); |
| 1193 | 1193 | } |
| 1194 | 1194 | |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $form = new DeployForm($this, 'DeployForm', $environment, $project); |
| 1197 | 1197 | |
| 1198 | 1198 | // If this is an ajax request we don't want to submit the form - we just want to retrieve the markup. |
| 1199 | - if ( |
|
| 1199 | + if( |
|
| 1200 | 1200 | $request && |
| 1201 | 1201 | !$request->requestVar('action_showDeploySummary') && |
| 1202 | 1202 | $this->getRequest()->isAjax() && |
@@ -1225,19 +1225,19 @@ discard block |
||
| 1225 | 1225 | |
| 1226 | 1226 | // Performs canView permission check by limiting visible projects |
| 1227 | 1227 | $project = $this->getCurrentProject(); |
| 1228 | - if (!$project) { |
|
| 1228 | + if(!$project) { |
|
| 1229 | 1229 | return $this->project404Response(); |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | // Performs canView permission check by limiting visible projects |
| 1233 | 1233 | $env = $this->getCurrentEnvironment($project); |
| 1234 | - if (!$env) { |
|
| 1234 | + if(!$env) { |
|
| 1235 | 1235 | return $this->environment404Response(); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | // For now only permit advanced options on one environment type, because we hacked the "full-deploy" |
| 1239 | 1239 | // checkbox in. Other environments such as the fast or capistrano one wouldn't know what to do with it. |
| 1240 | - if (get_class($env) === 'RainforestEnvironment') { |
|
| 1240 | + if(get_class($env) === 'RainforestEnvironment') { |
|
| 1241 | 1241 | $advanced = Permission::check('DEPLOYNAUT_ADVANCED_DEPLOY_OPTIONS') ? 'true' : 'false'; |
| 1242 | 1242 | } else { |
| 1243 | 1243 | $advanced = 'false'; |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | 'field_data' => array(), |
| 1255 | 1255 | 'advanced_opts' => $advanced |
| 1256 | 1256 | ); |
| 1257 | - foreach ($project->DNBranchList() as $branch) { |
|
| 1257 | + foreach($project->DNBranchList() as $branch) { |
|
| 1258 | 1258 | $sha = $branch->SHA(); |
| 1259 | 1259 | $name = $branch->Name(); |
| 1260 | 1260 | $branchValue = sprintf("%s (%s, %s old)", |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | 'advanced_opts' => $advanced |
| 1280 | 1280 | ); |
| 1281 | 1281 | |
| 1282 | - foreach ($project->DNTagList()->setLimit(null) as $tag) { |
|
| 1282 | + foreach($project->DNTagList()->setLimit(null) as $tag) { |
|
| 1283 | 1283 | $name = $tag->Name(); |
| 1284 | 1284 | $data['field_data'][] = array( |
| 1285 | 1285 | 'id' => $tag->SHA(), |
@@ -1305,15 +1305,15 @@ discard block |
||
| 1305 | 1305 | // We are aiming at the format: |
| 1306 | 1306 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
| 1307 | 1307 | $redeploy = array(); |
| 1308 | - foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1308 | + foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1309 | 1309 | $envName = $dnEnvironment->Name; |
| 1310 | 1310 | $perEnvDeploys = array(); |
| 1311 | 1311 | |
| 1312 | - foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1312 | + foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1313 | 1313 | $sha = $deploy->SHA; |
| 1314 | 1314 | |
| 1315 | 1315 | // Check if exists to make sure the newest deployment date is used. |
| 1316 | - if (!isset($perEnvDeploys[$sha])) { |
|
| 1316 | + if(!isset($perEnvDeploys[$sha])) { |
|
| 1317 | 1317 | $pastValue = sprintf("%s (deployed %s)", |
| 1318 | 1318 | substr($sha, 0, 8), |
| 1319 | 1319 | $deploy->obj('LastEdited')->Ago() |
@@ -1325,12 +1325,12 @@ discard block |
||
| 1325 | 1325 | } |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | - if (!empty($perEnvDeploys)) { |
|
| 1328 | + if(!empty($perEnvDeploys)) { |
|
| 1329 | 1329 | $redeploy[$envName] = array_values($perEnvDeploys); |
| 1330 | 1330 | } |
| 1331 | 1331 | } |
| 1332 | 1332 | // Convert the array to the frontend format (i.e. keyed to regular array) |
| 1333 | - foreach ($redeploy as $env => $descr) { |
|
| 1333 | + foreach($redeploy as $env => $descr) { |
|
| 1334 | 1334 | $data['field_data'][] = array('text'=>$env, 'children'=>$descr); |
| 1335 | 1335 | } |
| 1336 | 1336 | $tabs[] = $data; |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | ->filter('ProjectID', $project->ID) |
| 1353 | 1353 | ->sort('LastEdited', 'DESC') |
| 1354 | 1354 | ->first(); |
| 1355 | - if ($fetch) { |
|
| 1355 | + if($fetch) { |
|
| 1356 | 1356 | $lastFetched = $fetch->dbObject('LastEdited')->Ago(); |
| 1357 | 1357 | } |
| 1358 | 1358 | |
@@ -1378,7 +1378,7 @@ discard block |
||
| 1378 | 1378 | |
| 1379 | 1379 | // Ensure the submitted token has a value |
| 1380 | 1380 | $submittedToken = $request->postVar('SecurityID'); |
| 1381 | - if (!$submittedToken) { |
|
| 1381 | + if(!$submittedToken) { |
|
| 1382 | 1382 | return false; |
| 1383 | 1383 | } |
| 1384 | 1384 | |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | $check = $token->check($submittedToken); |
| 1387 | 1387 | |
| 1388 | 1388 | // Reset the token after we've checked the existing token |
| 1389 | - if ($resetToken) { |
|
| 1389 | + if($resetToken) { |
|
| 1390 | 1390 | $token->reset(); |
| 1391 | 1391 | } |
| 1392 | 1392 | |
@@ -1404,13 +1404,13 @@ discard block |
||
| 1404 | 1404 | |
| 1405 | 1405 | // Performs canView permission check by limiting visible projects |
| 1406 | 1406 | $project = $this->getCurrentProject(); |
| 1407 | - if (!$project) { |
|
| 1407 | + if(!$project) { |
|
| 1408 | 1408 | return $this->project404Response(); |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | 1411 | // Performs canView permission check by limiting visible projects |
| 1412 | 1412 | $environment = $this->getCurrentEnvironment($project); |
| 1413 | - if (!$environment) { |
|
| 1413 | + if(!$environment) { |
|
| 1414 | 1414 | return $this->environment404Response(); |
| 1415 | 1415 | } |
| 1416 | 1416 | |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | // Add in a URL for comparing from->to code changes. Ensure that we have |
| 1425 | 1425 | // two proper 40 character SHAs, otherwise we can't show the compare link. |
| 1426 | 1426 | $interface = $project->getRepositoryInterface(); |
| 1427 | - if ( |
|
| 1427 | + if( |
|
| 1428 | 1428 | !empty($interface) && !empty($interface->URL) |
| 1429 | 1429 | && !empty($data['changes']['Code version']['from']) |
| 1430 | 1430 | && strlen($data['changes']['Code version']['from']) == '40' |
@@ -1462,20 +1462,20 @@ discard block |
||
| 1462 | 1462 | { |
| 1463 | 1463 | |
| 1464 | 1464 | // Ensure the CSRF Token is correct |
| 1465 | - if (!$this->checkCsrfToken($request)) { |
|
| 1465 | + if(!$this->checkCsrfToken($request)) { |
|
| 1466 | 1466 | // CSRF token didn't match |
| 1467 | 1467 | return $this->httpError(400, 'Bad Request'); |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | // Performs canView permission check by limiting visible projects |
| 1471 | 1471 | $project = $this->getCurrentProject(); |
| 1472 | - if (!$project) { |
|
| 1472 | + if(!$project) { |
|
| 1473 | 1473 | return $this->project404Response(); |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // Performs canView permission check by limiting visible projects |
| 1477 | 1477 | $environment = $this->getCurrentEnvironment($project); |
| 1478 | - if (!$environment) { |
|
| 1478 | + if(!$environment) { |
|
| 1479 | 1479 | return $this->environment404Response(); |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1507,20 +1507,20 @@ discard block |
||
| 1507 | 1507 | $params = $request->params(); |
| 1508 | 1508 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 1509 | 1509 | |
| 1510 | - if (!$deployment || !$deployment->ID) { |
|
| 1510 | + if(!$deployment || !$deployment->ID) { |
|
| 1511 | 1511 | throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
| 1512 | 1512 | } |
| 1513 | - if (!$deployment->canView()) { |
|
| 1513 | + if(!$deployment->canView()) { |
|
| 1514 | 1514 | return Security::permissionFailure(); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | 1517 | $environment = $deployment->Environment(); |
| 1518 | 1518 | $project = $environment->Project(); |
| 1519 | 1519 | |
| 1520 | - if ($environment->Name != $params['Environment']) { |
|
| 1520 | + if($environment->Name != $params['Environment']) { |
|
| 1521 | 1521 | throw new LogicException("Environment in URL doesn't match this deploy"); |
| 1522 | 1522 | } |
| 1523 | - if ($project->Name != $params['Project']) { |
|
| 1523 | + if($project->Name != $params['Project']) { |
|
| 1524 | 1524 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1525 | 1525 | } |
| 1526 | 1526 | |
@@ -1543,25 +1543,25 @@ discard block |
||
| 1543 | 1543 | $params = $request->params(); |
| 1544 | 1544 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 1545 | 1545 | |
| 1546 | - if (!$deployment || !$deployment->ID) { |
|
| 1546 | + if(!$deployment || !$deployment->ID) { |
|
| 1547 | 1547 | throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
| 1548 | 1548 | } |
| 1549 | - if (!$deployment->canView()) { |
|
| 1549 | + if(!$deployment->canView()) { |
|
| 1550 | 1550 | return Security::permissionFailure(); |
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | $environment = $deployment->Environment(); |
| 1554 | 1554 | $project = $environment->Project(); |
| 1555 | 1555 | |
| 1556 | - if ($environment->Name != $params['Environment']) { |
|
| 1556 | + if($environment->Name != $params['Environment']) { |
|
| 1557 | 1557 | throw new LogicException("Environment in URL doesn't match this deploy"); |
| 1558 | 1558 | } |
| 1559 | - if ($project->Name != $params['Project']) { |
|
| 1559 | + if($project->Name != $params['Project']) { |
|
| 1560 | 1560 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | $log = $deployment->log(); |
| 1564 | - if ($log->exists()) { |
|
| 1564 | + if($log->exists()) { |
|
| 1565 | 1565 | $content = $log->content(); |
| 1566 | 1566 | } else { |
| 1567 | 1567 | $content = 'Waiting for action to start'; |
@@ -1578,11 +1578,11 @@ discard block |
||
| 1578 | 1578 | public function getDataTransferForm(SS_HTTPRequest $request = null) |
| 1579 | 1579 | { |
| 1580 | 1580 | // Performs canView permission check by limiting visible projects |
| 1581 | - $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 1581 | + $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 1582 | 1582 | return $item->canBackup(); |
| 1583 | 1583 | }); |
| 1584 | 1584 | |
| 1585 | - if (!$envs) { |
|
| 1585 | + if(!$envs) { |
|
| 1586 | 1586 | return $this->environment404Response(); |
| 1587 | 1587 | } |
| 1588 | 1588 | |
@@ -1618,21 +1618,21 @@ discard block |
||
| 1618 | 1618 | |
| 1619 | 1619 | // Performs canView permission check by limiting visible projects |
| 1620 | 1620 | $project = $this->getCurrentProject(); |
| 1621 | - if (!$project) { |
|
| 1621 | + if(!$project) { |
|
| 1622 | 1622 | return $this->project404Response(); |
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | $dataArchive = null; |
| 1626 | 1626 | |
| 1627 | 1627 | // Validate direction. |
| 1628 | - if ($data['Direction'] == 'get') { |
|
| 1628 | + if($data['Direction'] == 'get') { |
|
| 1629 | 1629 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 1630 | - ->filterByCallback(function ($item) { |
|
| 1630 | + ->filterByCallback(function($item) { |
|
| 1631 | 1631 | return $item->canBackup(); |
| 1632 | 1632 | }); |
| 1633 | - } elseif ($data['Direction'] == 'push') { |
|
| 1633 | + } elseif($data['Direction'] == 'push') { |
|
| 1634 | 1634 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 1635 | - ->filterByCallback(function ($item) { |
|
| 1635 | + ->filterByCallback(function($item) { |
|
| 1636 | 1636 | return $item->canRestore(); |
| 1637 | 1637 | }); |
| 1638 | 1638 | } else { |
@@ -1641,7 +1641,7 @@ discard block |
||
| 1641 | 1641 | |
| 1642 | 1642 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 1643 | 1643 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 1644 | - if (!$environment) { |
|
| 1644 | + if(!$environment) { |
|
| 1645 | 1645 | throw new LogicException('Invalid environment'); |
| 1646 | 1646 | } |
| 1647 | 1647 | |
@@ -1649,17 +1649,17 @@ discard block |
||
| 1649 | 1649 | |
| 1650 | 1650 | |
| 1651 | 1651 | // Only 'push' direction is allowed an association with an existing archive. |
| 1652 | - if ( |
|
| 1652 | + if( |
|
| 1653 | 1653 | $data['Direction'] == 'push' |
| 1654 | 1654 | && isset($data['DataArchiveID']) |
| 1655 | 1655 | && is_numeric($data['DataArchiveID']) |
| 1656 | 1656 | ) { |
| 1657 | 1657 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 1658 | - if (!$dataArchive) { |
|
| 1658 | + if(!$dataArchive) { |
|
| 1659 | 1659 | throw new LogicException('Invalid data archive'); |
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | - if (!$dataArchive->canDownload()) { |
|
| 1662 | + if(!$dataArchive->canDownload()) { |
|
| 1663 | 1663 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1664 | 1664 | } |
| 1665 | 1665 | } |
@@ -1669,7 +1669,7 @@ discard block |
||
| 1669 | 1669 | $transfer->Direction = $data['Direction']; |
| 1670 | 1670 | $transfer->Mode = $data['Mode']; |
| 1671 | 1671 | $transfer->DataArchiveID = $dataArchive ? $dataArchive->ID : null; |
| 1672 | - if ($data['Direction'] == 'push') { |
|
| 1672 | + if($data['Direction'] == 'push') { |
|
| 1673 | 1673 | $transfer->setBackupBeforePush(!empty($data['BackupBeforePush'])); |
| 1674 | 1674 | } |
| 1675 | 1675 | $transfer->write(); |
@@ -1693,17 +1693,17 @@ discard block |
||
| 1693 | 1693 | $params = $request->params(); |
| 1694 | 1694 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 1695 | 1695 | |
| 1696 | - if (!$transfer || !$transfer->ID) { |
|
| 1696 | + if(!$transfer || !$transfer->ID) { |
|
| 1697 | 1697 | throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
| 1698 | 1698 | } |
| 1699 | - if (!$transfer->canView()) { |
|
| 1699 | + if(!$transfer->canView()) { |
|
| 1700 | 1700 | return Security::permissionFailure(); |
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | 1703 | $environment = $transfer->Environment(); |
| 1704 | 1704 | $project = $environment->Project(); |
| 1705 | 1705 | |
| 1706 | - if ($project->Name != $params['Project']) { |
|
| 1706 | + if($project->Name != $params['Project']) { |
|
| 1707 | 1707 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1708 | 1708 | } |
| 1709 | 1709 | |
@@ -1728,22 +1728,22 @@ discard block |
||
| 1728 | 1728 | $params = $request->params(); |
| 1729 | 1729 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 1730 | 1730 | |
| 1731 | - if (!$transfer || !$transfer->ID) { |
|
| 1731 | + if(!$transfer || !$transfer->ID) { |
|
| 1732 | 1732 | throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
| 1733 | 1733 | } |
| 1734 | - if (!$transfer->canView()) { |
|
| 1734 | + if(!$transfer->canView()) { |
|
| 1735 | 1735 | return Security::permissionFailure(); |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | $environment = $transfer->Environment(); |
| 1739 | 1739 | $project = $environment->Project(); |
| 1740 | 1740 | |
| 1741 | - if ($project->Name != $params['Project']) { |
|
| 1741 | + if($project->Name != $params['Project']) { |
|
| 1742 | 1742 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1743 | 1743 | } |
| 1744 | 1744 | |
| 1745 | 1745 | $log = $transfer->log(); |
| 1746 | - if ($log->exists()) { |
|
| 1746 | + if($log->exists()) { |
|
| 1747 | 1747 | $content = $log->content(); |
| 1748 | 1748 | } else { |
| 1749 | 1749 | $content = 'Waiting for action to start'; |
@@ -1767,22 +1767,22 @@ discard block |
||
| 1767 | 1767 | |
| 1768 | 1768 | // Performs canView permission check by limiting visible projects |
| 1769 | 1769 | $project = $this->getCurrentProject(); |
| 1770 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 1770 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 1771 | 1771 | return $item->canRestore(); |
| 1772 | 1772 | }); |
| 1773 | 1773 | |
| 1774 | - if (!$envs) { |
|
| 1774 | + if(!$envs) { |
|
| 1775 | 1775 | return $this->environment404Response(); |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | 1778 | $modesMap = array(); |
| 1779 | - if (in_array($dataArchive->Mode, array('all'))) { |
|
| 1779 | + if(in_array($dataArchive->Mode, array('all'))) { |
|
| 1780 | 1780 | $modesMap['all'] = 'Database and Assets'; |
| 1781 | 1781 | }; |
| 1782 | - if (in_array($dataArchive->Mode, array('all', 'db'))) { |
|
| 1782 | + if(in_array($dataArchive->Mode, array('all', 'db'))) { |
|
| 1783 | 1783 | $modesMap['db'] = 'Database only'; |
| 1784 | 1784 | }; |
| 1785 | - if (in_array($dataArchive->Mode, array('all', 'assets'))) { |
|
| 1785 | + if(in_array($dataArchive->Mode, array('all', 'assets'))) { |
|
| 1786 | 1786 | $modesMap['assets'] = 'Assets only'; |
| 1787 | 1787 | }; |
| 1788 | 1788 | |
@@ -1828,13 +1828,13 @@ discard block |
||
| 1828 | 1828 | /** @var DNDataArchive $dataArchive */ |
| 1829 | 1829 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1830 | 1830 | |
| 1831 | - if (!$dataArchive) { |
|
| 1831 | + if(!$dataArchive) { |
|
| 1832 | 1832 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | // We check for canDownload because that implies access to the data. |
| 1836 | 1836 | // canRestore is later checked on the actual restore action per environment. |
| 1837 | - if (!$dataArchive->canDownload()) { |
|
| 1837 | + if(!$dataArchive->canDownload()) { |
|
| 1838 | 1838 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1839 | 1839 | } |
| 1840 | 1840 | |
@@ -1861,11 +1861,11 @@ discard block |
||
| 1861 | 1861 | /** @var DNDataArchive $dataArchive */ |
| 1862 | 1862 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1863 | 1863 | |
| 1864 | - if (!$dataArchive) { |
|
| 1864 | + if(!$dataArchive) { |
|
| 1865 | 1865 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | - if (!$dataArchive->canDelete()) { |
|
| 1868 | + if(!$dataArchive->canDelete()) { |
|
| 1869 | 1869 | throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403); |
| 1870 | 1870 | } |
| 1871 | 1871 | |
@@ -1887,7 +1887,7 @@ discard block |
||
| 1887 | 1887 | |
| 1888 | 1888 | // Performs canView permission check by limiting visible projects |
| 1889 | 1889 | $project = $this->getCurrentProject(); |
| 1890 | - if (!$project) { |
|
| 1890 | + if(!$project) { |
|
| 1891 | 1891 | return $this->project404Response(); |
| 1892 | 1892 | } |
| 1893 | 1893 | |
@@ -1925,24 +1925,24 @@ discard block |
||
| 1925 | 1925 | |
| 1926 | 1926 | // Performs canView permission check by limiting visible projects |
| 1927 | 1927 | $project = $this->getCurrentProject(); |
| 1928 | - if (!$project) { |
|
| 1928 | + if(!$project) { |
|
| 1929 | 1929 | return $this->project404Response(); |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | $dataArchive = null; |
| 1933 | 1933 | |
| 1934 | - if ( |
|
| 1934 | + if( |
|
| 1935 | 1935 | isset($data['DataArchiveID']) |
| 1936 | 1936 | && is_numeric($data['DataArchiveID']) |
| 1937 | 1937 | ) { |
| 1938 | 1938 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 1939 | 1939 | } |
| 1940 | 1940 | |
| 1941 | - if (!$dataArchive) { |
|
| 1941 | + if(!$dataArchive) { |
|
| 1942 | 1942 | throw new LogicException('Invalid data archive'); |
| 1943 | 1943 | } |
| 1944 | 1944 | |
| 1945 | - if (!$dataArchive->canDelete()) { |
|
| 1945 | + if(!$dataArchive->canDelete()) { |
|
| 1946 | 1946 | throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403); |
| 1947 | 1947 | } |
| 1948 | 1948 | |
@@ -1966,12 +1966,12 @@ discard block |
||
| 1966 | 1966 | /** @var DNDataArchive $dataArchive */ |
| 1967 | 1967 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1968 | 1968 | |
| 1969 | - if (!$dataArchive) { |
|
| 1969 | + if(!$dataArchive) { |
|
| 1970 | 1970 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | 1973 | // We check for canDownload because that implies access to the data. |
| 1974 | - if (!$dataArchive->canDownload()) { |
|
| 1974 | + if(!$dataArchive->canDownload()) { |
|
| 1975 | 1975 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1976 | 1976 | } |
| 1977 | 1977 | |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID')); |
| 1995 | 1995 | |
| 1996 | 1996 | $envs = $dataArchive->validTargetEnvironments(); |
| 1997 | - if (!$envs) { |
|
| 1997 | + if(!$envs) { |
|
| 1998 | 1998 | return $this->environment404Response(); |
| 1999 | 1999 | } |
| 2000 | 2000 | |
@@ -2036,25 +2036,25 @@ discard block |
||
| 2036 | 2036 | |
| 2037 | 2037 | // Performs canView permission check by limiting visible projects |
| 2038 | 2038 | $project = $this->getCurrentProject(); |
| 2039 | - if (!$project) { |
|
| 2039 | + if(!$project) { |
|
| 2040 | 2040 | return $this->project404Response(); |
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | /** @var DNDataArchive $dataArchive */ |
| 2044 | 2044 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 2045 | - if (!$dataArchive) { |
|
| 2045 | + if(!$dataArchive) { |
|
| 2046 | 2046 | throw new LogicException('Invalid data archive'); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | 2049 | // We check for canDownload because that implies access to the data. |
| 2050 | - if (!$dataArchive->canDownload()) { |
|
| 2050 | + if(!$dataArchive->canDownload()) { |
|
| 2051 | 2051 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 2055 | 2055 | $validEnvs = $dataArchive->validTargetEnvironments(); |
| 2056 | 2056 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 2057 | - if (!$environment) { |
|
| 2057 | + if(!$environment) { |
|
| 2058 | 2058 | throw new LogicException('Invalid environment'); |
| 2059 | 2059 | } |
| 2060 | 2060 | |
@@ -2073,7 +2073,7 @@ discard block |
||
| 2073 | 2073 | { |
| 2074 | 2074 | try { |
| 2075 | 2075 | Resque::queues(); |
| 2076 | - } catch (Exception $e) { |
|
| 2076 | + } catch(Exception $e) { |
|
| 2077 | 2077 | return $e->getMessage(); |
| 2078 | 2078 | } |
| 2079 | 2079 | return ''; |
@@ -2140,10 +2140,10 @@ discard block |
||
| 2140 | 2140 | public function getCurrentProject() |
| 2141 | 2141 | { |
| 2142 | 2142 | $projectName = trim($this->getRequest()->param('Project')); |
| 2143 | - if (!$projectName) { |
|
| 2143 | + if(!$projectName) { |
|
| 2144 | 2144 | return null; |
| 2145 | 2145 | } |
| 2146 | - if (empty(self::$_project_cache[$projectName])) { |
|
| 2146 | + if(empty(self::$_project_cache[$projectName])) { |
|
| 2147 | 2147 | self::$_project_cache[$projectName] = $this->DNProjectList()->filter('Name', $projectName)->First(); |
| 2148 | 2148 | } |
| 2149 | 2149 | return self::$_project_cache[$projectName]; |
@@ -2155,14 +2155,14 @@ discard block |
||
| 2155 | 2155 | */ |
| 2156 | 2156 | public function getCurrentEnvironment(DNProject $project = null) |
| 2157 | 2157 | { |
| 2158 | - if ($this->getRequest()->param('Environment') === null) { |
|
| 2158 | + if($this->getRequest()->param('Environment') === null) { |
|
| 2159 | 2159 | return null; |
| 2160 | 2160 | } |
| 2161 | - if ($project === null) { |
|
| 2161 | + if($project === null) { |
|
| 2162 | 2162 | $project = $this->getCurrentProject(); |
| 2163 | 2163 | } |
| 2164 | 2164 | // project can still be null |
| 2165 | - if ($project === null) { |
|
| 2165 | + if($project === null) { |
|
| 2166 | 2166 | return null; |
| 2167 | 2167 | } |
| 2168 | 2168 | return $project->DNEnvironmentList()->filter('Name', $this->getRequest()->param('Environment'))->First(); |
@@ -2204,23 +2204,23 @@ discard block |
||
| 2204 | 2204 | */ |
| 2205 | 2205 | public function CanViewArchives(Member $member = null) |
| 2206 | 2206 | { |
| 2207 | - if ($member === null) { |
|
| 2207 | + if($member === null) { |
|
| 2208 | 2208 | $member = Member::currentUser(); |
| 2209 | 2209 | } |
| 2210 | 2210 | |
| 2211 | - if (Permission::checkMember($member, 'ADMIN')) { |
|
| 2211 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 2212 | 2212 | return true; |
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | 2215 | $allProjects = $this->DNProjectList(); |
| 2216 | - if (!$allProjects) { |
|
| 2216 | + if(!$allProjects) { |
|
| 2217 | 2217 | return false; |
| 2218 | 2218 | } |
| 2219 | 2219 | |
| 2220 | - foreach ($allProjects as $project) { |
|
| 2221 | - if ($project->Environments()) { |
|
| 2222 | - foreach ($project->Environments() as $environment) { |
|
| 2223 | - if ( |
|
| 2220 | + foreach($allProjects as $project) { |
|
| 2221 | + if($project->Environments()) { |
|
| 2222 | + foreach($project->Environments() as $environment) { |
|
| 2223 | + if( |
|
| 2224 | 2224 | $environment->canRestore($member) || |
| 2225 | 2225 | $environment->canBackup($member) || |
| 2226 | 2226 | $environment->canUploadArchive($member) || |
@@ -2242,7 +2242,7 @@ discard block |
||
| 2242 | 2242 | public function CreateEnvironmentList() |
| 2243 | 2243 | { |
| 2244 | 2244 | $project = $this->getCurrentProject(); |
| 2245 | - if ($project) { |
|
| 2245 | + if($project) { |
|
| 2246 | 2246 | return new PaginatedList($project->CreateEnvironments()->sort("Created DESC"), $this->request); |
| 2247 | 2247 | } |
| 2248 | 2248 | return new PaginatedList(new ArrayList(), $this->request); |
@@ -2259,9 +2259,9 @@ discard block |
||
| 2259 | 2259 | $archives = new ArrayList(); |
| 2260 | 2260 | |
| 2261 | 2261 | $archiveList = $project->Environments()->relation("DataArchives"); |
| 2262 | - if ($archiveList->count() > 0) { |
|
| 2263 | - foreach ($archiveList as $archive) { |
|
| 2264 | - if ($archive->canView() && !$archive->isPending()) { |
|
| 2262 | + if($archiveList->count() > 0) { |
|
| 2263 | + foreach($archiveList as $archive) { |
|
| 2264 | + if($archive->canView() && !$archive->isPending()) { |
|
| 2265 | 2265 | $archives->push($archive); |
| 2266 | 2266 | } |
| 2267 | 2267 | } |
@@ -2277,9 +2277,9 @@ discard block |
||
| 2277 | 2277 | { |
| 2278 | 2278 | $project = $this->getCurrentProject(); |
| 2279 | 2279 | $archives = new ArrayList(); |
| 2280 | - foreach ($project->DNEnvironmentList() as $env) { |
|
| 2281 | - foreach ($env->DataArchives() as $archive) { |
|
| 2282 | - if ($archive->canView() && $archive->isPending()) { |
|
| 2280 | + foreach($project->DNEnvironmentList() as $env) { |
|
| 2281 | + foreach($env->DataArchives() as $archive) { |
|
| 2282 | + if($archive->canView() && $archive->isPending()) { |
|
| 2283 | 2283 | $archives->push($archive); |
| 2284 | 2284 | } |
| 2285 | 2285 | } |
@@ -2294,7 +2294,7 @@ discard block |
||
| 2294 | 2294 | { |
| 2295 | 2295 | $project = $this->getCurrentProject(); |
| 2296 | 2296 | |
| 2297 | - $transfers = DNDataTransfer::get()->filterByCallback(function ($record) use ($project) { |
|
| 2297 | + $transfers = DNDataTransfer::get()->filterByCallback(function($record) use ($project) { |
|
| 2298 | 2298 | return |
| 2299 | 2299 | $record->Environment()->Project()->ID == $project->ID && // Ensure only the current Project is shown |
| 2300 | 2300 | ( |
@@ -2313,9 +2313,9 @@ discard block |
||
| 2313 | 2313 | */ |
| 2314 | 2314 | public function DeployHistory() |
| 2315 | 2315 | { |
| 2316 | - if ($env = $this->getCurrentEnvironment()) { |
|
| 2316 | + if($env = $this->getCurrentEnvironment()) { |
|
| 2317 | 2317 | $history = $env->DeployHistory(); |
| 2318 | - if ($history->count() > 0) { |
|
| 2318 | + if($history->count() > 0) { |
|
| 2319 | 2319 | $pagination = new PaginatedList($history, $this->getRequest()); |
| 2320 | 2320 | $pagination->setPageLength(8); |
| 2321 | 2321 | return $pagination; |
@@ -2358,7 +2358,7 @@ discard block |
||
| 2358 | 2358 | $sendJSON = (strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) |
| 2359 | 2359 | || $this->getRequest()->getExtension() == 'json'; |
| 2360 | 2360 | |
| 2361 | - if (!$sendJSON) { |
|
| 2361 | + if(!$sendJSON) { |
|
| 2362 | 2362 | $this->response->addHeader("Content-type", "text/plain"); |
| 2363 | 2363 | return $content; |
| 2364 | 2364 | } |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | */ |
| 2377 | 2377 | protected function validateSnapshotMode($mode) |
| 2378 | 2378 | { |
| 2379 | - if (!in_array($mode, array('all', 'assets', 'db'))) { |
|
| 2379 | + if(!in_array($mode, array('all', 'assets', 'db'))) { |
|
| 2380 | 2380 | throw new LogicException('Invalid mode'); |
| 2381 | 2381 | } |
| 2382 | 2382 | } |
@@ -2391,12 +2391,12 @@ discard block |
||
| 2391 | 2391 | { |
| 2392 | 2392 | // Performs canView permission check by limiting visible projects |
| 2393 | 2393 | $project = $this->getCurrentProject(); |
| 2394 | - if (!$project) { |
|
| 2394 | + if(!$project) { |
|
| 2395 | 2395 | return $this->project404Response(); |
| 2396 | 2396 | } |
| 2397 | 2397 | $data[$sectionName] = 1; |
| 2398 | 2398 | |
| 2399 | - if ($this !== '') { |
|
| 2399 | + if($this !== '') { |
|
| 2400 | 2400 | $data['Title'] = $title; |
| 2401 | 2401 | } |
| 2402 | 2402 | |
@@ -2412,7 +2412,7 @@ discard block |
||
| 2412 | 2412 | { |
| 2413 | 2413 | $list = new ArrayList(); |
| 2414 | 2414 | |
| 2415 | - if (Member::currentUserID()) { |
|
| 2415 | + if(Member::currentUserID()) { |
|
| 2416 | 2416 | $list->push(new ArrayData(array( |
| 2417 | 2417 | 'Classes' => 'logout', |
| 2418 | 2418 | 'FaIcon' => 'sign-out', |
@@ -2434,7 +2434,7 @@ discard block |
||
| 2434 | 2434 | */ |
| 2435 | 2435 | public function createproject(SS_HTTPRequest $request) |
| 2436 | 2436 | { |
| 2437 | - if ($this->canCreateProjects()) { |
|
| 2437 | + if($this->canCreateProjects()) { |
|
| 2438 | 2438 | return $this->render(['CurrentTitle' => 'Create Stack']); |
| 2439 | 2439 | } |
| 2440 | 2440 | return $this->httpError(403); |
@@ -2447,10 +2447,10 @@ discard block |
||
| 2447 | 2447 | */ |
| 2448 | 2448 | public function canCreateProjects($member = null) |
| 2449 | 2449 | { |
| 2450 | - if (!$member) { |
|
| 2450 | + if(!$member) { |
|
| 2451 | 2451 | $member = Member::currentUser(); |
| 2452 | 2452 | } |
| 2453 | - if (!$member) { |
|
| 2453 | + if(!$member) { |
|
| 2454 | 2454 | return false; |
| 2455 | 2455 | } |
| 2456 | 2456 | |
@@ -2515,11 +2515,11 @@ discard block |
||
| 2515 | 2515 | $form->saveInto($project); |
| 2516 | 2516 | $this->extend('onBeforeCreateProject', $project, $data, $form); |
| 2517 | 2517 | try { |
| 2518 | - if ($project->write() > 0) { |
|
| 2518 | + if($project->write() > 0) { |
|
| 2519 | 2519 | $this->extend('onAfterCreateProject', $project, $data, $form); |
| 2520 | 2520 | |
| 2521 | 2521 | // If an extension hasn't redirected us, we'll redirect to the project. |
| 2522 | - if (!$this->redirectedTo()) { |
|
| 2522 | + if(!$this->redirectedTo()) { |
|
| 2523 | 2523 | return $this->redirect($project->Link()); |
| 2524 | 2524 | } else { |
| 2525 | 2525 | return $this->response; |
@@ -2527,7 +2527,7 @@ discard block |
||
| 2527 | 2527 | } else { |
| 2528 | 2528 | $form->sessionMessage('Unable to write the stack to the database.', 'bad'); |
| 2529 | 2529 | } |
| 2530 | - } catch (ValidationException $e) { |
|
| 2530 | + } catch(ValidationException $e) { |
|
| 2531 | 2531 | $form->sessionMessage($e->getMessage(), 'bad'); |
| 2532 | 2532 | } |
| 2533 | 2533 | return $this->redirectBack(); |
@@ -2543,7 +2543,7 @@ discard block |
||
| 2543 | 2543 | public function createprojectprogress(SS_HTTPRequest $request) |
| 2544 | 2544 | { |
| 2545 | 2545 | $project = $this->getCurrentProject(); |
| 2546 | - if (!$project) { |
|
| 2546 | + if(!$project) { |
|
| 2547 | 2547 | return $this->httpError(404); |
| 2548 | 2548 | } |
| 2549 | 2549 | |
@@ -2551,13 +2551,13 @@ discard block |
||
| 2551 | 2551 | $complete = array(); |
| 2552 | 2552 | $inProgress = array(); |
| 2553 | 2553 | $failed = array(); |
| 2554 | - if ($envCreations->count() > 0) { |
|
| 2555 | - foreach ($envCreations as $env) { |
|
| 2554 | + if($envCreations->count() > 0) { |
|
| 2555 | + foreach($envCreations as $env) { |
|
| 2556 | 2556 | $data = unserialize($env->Data); |
| 2557 | - if (!isset($data['Name'])) { |
|
| 2557 | + if(!isset($data['Name'])) { |
|
| 2558 | 2558 | $data['Name'] = 'Unknown'; |
| 2559 | 2559 | } |
| 2560 | - switch ($env->ResqueStatus()) { |
|
| 2560 | + switch($env->ResqueStatus()) { |
|
| 2561 | 2561 | case "Queued": |
| 2562 | 2562 | case "Running": |
| 2563 | 2563 | $inProgress[$env->ID] = Convert::raw2xml($env->ResqueStatus()); |
@@ -2594,17 +2594,17 @@ discard block |
||
| 2594 | 2594 | public function checkrepoaccess(SS_HTTPRequest $request) |
| 2595 | 2595 | { |
| 2596 | 2596 | $project = $this->getCurrentProject(); |
| 2597 | - if (!$project) { |
|
| 2597 | + if(!$project) { |
|
| 2598 | 2598 | return $this->httpError(404); |
| 2599 | 2599 | } |
| 2600 | 2600 | |
| 2601 | - if ($project->CVSPath) { |
|
| 2601 | + if($project->CVSPath) { |
|
| 2602 | 2602 | $fetch = new FetchJob(); |
| 2603 | 2603 | $fetch->args = array('projectID' => $project->ID); |
| 2604 | 2604 | try { |
| 2605 | 2605 | $fetch->perform(); |
| 2606 | 2606 | $canAccessRepo = true; |
| 2607 | - } catch (RuntimeException $e) { |
|
| 2607 | + } catch(RuntimeException $e) { |
|
| 2608 | 2608 | $canAccessRepo = false; |
| 2609 | 2609 | } |
| 2610 | 2610 | $data = ['canAccessRepo' => $canAccessRepo]; |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | 'projects' => array(), |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - if ($request->httpMethod() != 'GET') { |
|
| 56 | + if($request->httpMethod() != 'GET') { |
|
| 57 | 57 | return $this->message('API not found', 404); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - foreach (DNProject::get() as $item) { |
|
| 61 | - if ($item->canView($this->getMember())) { |
|
| 60 | + foreach(DNProject::get() as $item) { |
|
| 61 | + if($item->canView($this->getMember())) { |
|
| 62 | 62 | $response['projects'][] = array( |
| 63 | 63 | "name" => $item->Name, |
| 64 | 64 | "href" => Director::absoluteURL($item->APILink("")), |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function project(SS_HTTPRequest $request) |
| 79 | 79 | { |
| 80 | 80 | $project = $this->getProject(); |
| 81 | - if (!$project) { |
|
| 81 | + if(!$project) { |
|
| 82 | 82 | return $this->project404Response(); |
| 83 | 83 | } |
| 84 | 84 | return new APIProject($this, $project); |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | public function environment(SS_HTTPRequest $request) |
| 94 | 94 | { |
| 95 | 95 | $project = $this->getProject(); |
| 96 | - if (!$project) { |
|
| 96 | + if(!$project) { |
|
| 97 | 97 | return $this->project404Response(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $environment = $this->getEnvironment(); |
| 101 | - if (!$environment) { |
|
| 101 | + if(!$environment) { |
|
| 102 | 102 | return $this->environment404Response(); |
| 103 | 103 | } |
| 104 | 104 | return new APIEnvironment($this, $environment); |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index(SS_HTTPRequest $request) |
| 19 | 19 | { |
| 20 | - if (!$this->record->canView($this->getMember())) { |
|
| 20 | + if(!$this->record->canView($this->getMember())) { |
|
| 21 | 21 | return $this->message('You are not authorized to view this environment', 403); |
| 22 | 22 | } |
| 23 | - switch ($request->httpMethod()) { |
|
| 23 | + switch($request->httpMethod()) { |
|
| 24 | 24 | case 'GET': |
| 25 | 25 | $href = Director::absoluteURL($this->record->Project()->APILink($this->record->Name)); |
| 26 | 26 | return $this->getAPIResponse(array( |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function ping(SS_HTTPRequest $request) |
| 56 | 56 | { |
| 57 | - if (!$this->record->canView($this->getMember())) { |
|
| 57 | + if(!$this->record->canView($this->getMember())) { |
|
| 58 | 58 | return $this->message('You are not authorized to do that on this environment', 403); |
| 59 | 59 | } |
| 60 | - switch ($request->httpMethod()) { |
|
| 60 | + switch($request->httpMethod()) { |
|
| 61 | 61 | case 'GET': |
| 62 | 62 | return $this->getPing($this->getRequest()->param('ID')); |
| 63 | 63 | case 'POST': |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function deploy(SS_HTTPRequest $request) |
| 75 | 75 | { |
| 76 | - if (!$this->record->canView($this->getMember())) { |
|
| 76 | + if(!$this->record->canView($this->getMember())) { |
|
| 77 | 77 | return $this->message('You are not authorized to do that on this environment', 403); |
| 78 | 78 | } |
| 79 | - switch ($request->httpMethod()) { |
|
| 79 | + switch($request->httpMethod()) { |
|
| 80 | 80 | case 'GET': |
| 81 | 81 | return $this->getDeploy($this->getRequest()->param('ID')); |
| 82 | 82 | case 'POST': |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function createPing() |
| 113 | 113 | { |
| 114 | - if (!$this->record->canDeploy($this->getMember())) { |
|
| 114 | + if(!$this->record->canDeploy($this->getMember())) { |
|
| 115 | 115 | return $this->message('You are not authorized to do that on this environment', 403); |
| 116 | 116 | } |
| 117 | 117 | $ping = DNPing::create(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | protected function getPing($ID) |
| 139 | 139 | { |
| 140 | 140 | $ping = DNPing::get()->byID($ID); |
| 141 | - if (!$ping) { |
|
| 141 | + if(!$ping) { |
|
| 142 | 142 | return $this->message('Ping not found', 404); |
| 143 | 143 | } |
| 144 | 144 | $output = array( |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function createDeploy() |
| 156 | 156 | { |
| 157 | - if (!$this->record->canDeploy($this->getMember())) { |
|
| 157 | + if(!$this->record->canDeploy($this->getMember())) { |
|
| 158 | 158 | return $this->message('You are not authorized to do that on this environment', 403); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $reqBody = $this->getRequestBody(); |
| 162 | 162 | |
| 163 | - if ($reqBody === null) { |
|
| 163 | + if($reqBody === null) { |
|
| 164 | 164 | return $this->message('the request body did not contain a valid JSON object.', 400); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if (empty($reqBody['release'])) { |
|
| 167 | + if(empty($reqBody['release'])) { |
|
| 168 | 168 | return $this->message('deploy requires a {"release": "sha1"} in the body of the request.', 400); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | protected function getDeploy($id) |
| 192 | 192 | { |
| 193 | 193 | $deploy = DNDeployment::get()->byID($id); |
| 194 | - if (!$deploy) { |
|
| 194 | + if(!$deploy) { |
|
| 195 | 195 | return $this->message('Deploy not found', 404); |
| 196 | 196 | } |
| 197 | 197 | $output = array( |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | protected function getAPIResponse($output) |
| 66 | 66 | { |
| 67 | 67 | $response = $this->getResponse(); |
| 68 | - if ($this->respondWithText()) { |
|
| 68 | + if($this->respondWithText()) { |
|
| 69 | 69 | $body = print_r($output, true); |
| 70 | 70 | $response->addHeader('Content-Type', 'text/plain'); |
| 71 | 71 | } else { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function respondWithJSON() |
| 83 | 83 | { |
| 84 | - if ($this->getRequest()->getExtension() == 'json') { |
|
| 84 | + if($this->getRequest()->getExtension() == 'json') { |
|
| 85 | 85 | return true; |
| 86 | 86 | } |
| 87 | - if (strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) { |
|
| 87 | + if(strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) { |
|
| 88 | 88 | return true; |
| 89 | 89 | } |
| 90 | 90 | return false; |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function respondWithText() |
| 97 | 97 | { |
| 98 | - if ($this->getRequest()->getExtension() == 'txt') { |
|
| 98 | + if($this->getRequest()->getExtension() == 'txt') { |
|
| 99 | 99 | return true; |
| 100 | 100 | } |
| 101 | - if (strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) { |
|
| 101 | + if(strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) { |
|
| 102 | 102 | return true; |
| 103 | 103 | } |
| 104 | 104 | return false; |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index(SS_HTTPRequest $request) |
| 19 | 19 | { |
| 20 | - if (!$this->record->canView($this->getMember())) { |
|
| 20 | + if(!$this->record->canView($this->getMember())) { |
|
| 21 | 21 | return $this->message('You are not authorized to this environment', 403); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - switch ($request->httpMethod()) { |
|
| 24 | + switch($request->httpMethod()) { |
|
| 25 | 25 | case 'GET': |
| 26 | 26 | $response = array( |
| 27 | 27 | "name" => $this->record->Name, |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | "disk-quota-mb" => $this->record->DiskQuotaMB, |
| 32 | 32 | "environments" => array(), |
| 33 | 33 | ); |
| 34 | - foreach ($this->record->DNEnvironmentList() as $environment) { |
|
| 34 | + foreach($this->record->DNEnvironmentList() as $environment) { |
|
| 35 | 35 | $response['environments'][] = array( |
| 36 | 36 | 'name' => $environment->Name, |
| 37 | 37 | 'href' => Director::absoluteURL($this->record->APILink($environment->Name)), |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function fetch(SS_HTTPRequest $request) |
| 52 | 52 | { |
| 53 | - if (!$this->record->canView($this->getMember())) { |
|
| 53 | + if(!$this->record->canView($this->getMember())) { |
|
| 54 | 54 | return $this->message('You are not authorized to do that on this environment', 403); |
| 55 | 55 | } |
| 56 | - switch ($request->httpMethod()) { |
|
| 56 | + switch($request->httpMethod()) { |
|
| 57 | 57 | case 'GET': |
| 58 | 58 | return $this->getFetch($this->getRequest()->param('ID')); |
| 59 | 59 | case 'POST': |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | protected function getFetch($ID) |
| 71 | 71 | { |
| 72 | 72 | $ping = DNGitFetch::get()->byID($ID); |
| 73 | - if (!$ping) { |
|
| 73 | + if(!$ping) { |
|
| 74 | 74 | return $this->message('Fetch not found', 404); |
| 75 | 75 | } |
| 76 | 76 | $output = array( |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $currentBuild = $environment->CurrentBuild(); |
| 32 | 32 | $currentSha = $currentBuild ? $currentBuild->SHA : '-'; |
| 33 | - if ($currentSha !== $options['sha']) { |
|
| 33 | + if($currentSha !== $options['sha']) { |
|
| 34 | 34 | $strategy->setChange('Code version', $currentSha, $options['sha']); |
| 35 | 35 | } |
| 36 | 36 | $strategy->setActionTitle('Confirm deployment'); |
@@ -71,53 +71,53 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour |
| 73 | 73 | // if build_filename isn't specified |
| 74 | - if ($this->packageGenerator) { |
|
| 74 | + if($this->packageGenerator) { |
|
| 75 | 75 | $log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator))); |
| 76 | 76 | |
| 77 | 77 | try { |
| 78 | 78 | $args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log); |
| 79 | - } catch (Exception $e) { |
|
| 79 | + } catch(Exception $e) { |
|
| 80 | 80 | $log->write($e->getMessage()); |
| 81 | 81 | throw $e; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (empty($args['build_filename'])) { |
|
| 84 | + if(empty($args['build_filename'])) { |
|
| 85 | 85 | throw new RuntimeException('Failed to generate package.'); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $command = $this->getCommand('deploy', 'web', $environment, $args, $log); |
| 90 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 90 | + $command->run(function($type, $buffer) use ($log) { |
|
| 91 | 91 | $log->write($buffer); |
| 92 | 92 | }); |
| 93 | 93 | |
| 94 | 94 | // Deployment cleanup. We assume it is always safe to run this at the end, regardless of the outcome. |
| 95 | 95 | $self = $this; |
| 96 | - $cleanupFn = function () use ($self, $environment, $args, $log) { |
|
| 96 | + $cleanupFn = function() use ($self, $environment, $args, $log) { |
|
| 97 | 97 | $command = $self->getCommand('deploy:cleanup', 'web', $environment, $args, $log); |
| 98 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 98 | + $command->run(function($type, $buffer) use ($log) { |
|
| 99 | 99 | $log->write($buffer); |
| 100 | 100 | }); |
| 101 | 101 | |
| 102 | - if (!$command->isSuccessful()) { |
|
| 102 | + if(!$command->isSuccessful()) { |
|
| 103 | 103 | $this->extend('cleanupFailure', $environment, $sha, $log, $project); |
| 104 | 104 | $log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.'); |
| 105 | 105 | } |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | // Once the deployment has run it's necessary to update the maintenance page status |
| 109 | - if (!empty($options['leaveMaintenancePage'])) { |
|
| 109 | + if(!empty($options['leaveMaintenancePage'])) { |
|
| 110 | 110 | $this->enableMaintenance($environment, $log, $project); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if (!$command->isSuccessful()) { |
|
| 113 | + if(!$command->isSuccessful()) { |
|
| 114 | 114 | $cleanupFn(); |
| 115 | 115 | $this->extend('deployFailure', $environment, $sha, $log, $project); |
| 116 | 116 | throw new RuntimeException($command->getErrorOutput()); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Check if maintenance page should be removed |
| 120 | - if (empty($options['leaveMaintenancePage'])) { |
|
| 120 | + if(empty($options['leaveMaintenancePage'])) { |
|
| 121 | 121 | $this->disableMaintenance($environment, $log, $project); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $name = $environment->getFullName(); |
| 137 | 137 | $command = $this->getCommand('maintenance:enable', 'web', $environment, null, $log); |
| 138 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 138 | + $command->run(function($type, $buffer) use ($log) { |
|
| 139 | 139 | $log->write($buffer); |
| 140 | 140 | }); |
| 141 | - if (!$command->isSuccessful()) { |
|
| 141 | + if(!$command->isSuccessful()) { |
|
| 142 | 142 | $this->extend('maintenanceEnableFailure', $environment, $log); |
| 143 | 143 | throw new RuntimeException($command->getErrorOutput()); |
| 144 | 144 | } |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $name = $environment->getFullName(); |
| 154 | 154 | $command = $this->getCommand('maintenance:disable', 'web', $environment, null, $log); |
| 155 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 155 | + $command->run(function($type, $buffer) use ($log) { |
|
| 156 | 156 | $log->write($buffer); |
| 157 | 157 | }); |
| 158 | - if (!$command->isSuccessful()) { |
|
| 158 | + if(!$command->isSuccessful()) { |
|
| 159 | 159 | $this->extend('maintenanceDisableFailure', $environment, $log); |
| 160 | 160 | throw new RuntimeException($command->getErrorOutput()); |
| 161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) |
| 169 | 169 | { |
| 170 | 170 | $command = $this->getCommand('deploy:check', 'web', $environment, null, $log); |
| 171 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 171 | + $command->run(function($type, $buffer) use ($log) { |
|
| 172 | 172 | $log->write($buffer); |
| 173 | 173 | echo $buffer; |
| 174 | 174 | }); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) |
| 181 | 181 | { |
| 182 | - if ($dataTransfer->Direction == 'get') { |
|
| 182 | + if($dataTransfer->Direction == 'get') { |
|
| 183 | 183 | $this->dataTransferBackup($dataTransfer, $log); |
| 184 | 184 | } else { |
| 185 | 185 | $environment = $dataTransfer->Environment(); |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | // extract the sspak contents, we'll need these so capistrano can restore that content |
| 191 | 191 | try { |
| 192 | 192 | $archive->extractArchive($workingDir); |
| 193 | - } catch (Exception $e) { |
|
| 193 | + } catch(Exception $e) { |
|
| 194 | 194 | $log->write($e->getMessage()); |
| 195 | 195 | throw new RuntimeException($e->getMessage()); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // validate the contents match the requested transfer mode |
| 199 | 199 | $result = $archive->validateArchiveContents($dataTransfer->Mode); |
| 200 | - if (!$result->valid()) { |
|
| 200 | + if(!$result->valid()) { |
|
| 201 | 201 | // do some cleaning, get rid of the extracted archive lying around |
| 202 | 202 | $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
| 203 | 203 | $process->run(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $name = $environment->getFullName(); |
| 228 | 228 | $env = $environment->Project()->getProcessEnv(); |
| 229 | 229 | |
| 230 | - if (!$args) { |
|
| 230 | + if(!$args) { |
|
| 231 | 231 | $args = array(); |
| 232 | 232 | } |
| 233 | 233 | $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | // Inject env string directly into the command. |
| 236 | 236 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
| 237 | 237 | $envString = ''; |
| 238 | - if (!empty($env)) { |
|
| 238 | + if(!empty($env)) { |
|
| 239 | 239 | $envString .= 'env '; |
| 240 | - foreach ($env as $key => $value) { |
|
| 240 | + foreach($env as $key => $value) { |
|
| 241 | 241 | $envString .= "$key=\"$value\" "; |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $capTemplate |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if (defined('DEPLOYNAUT_CAPFILE')) { |
|
| 254 | + if(defined('DEPLOYNAUT_CAPFILE')) { |
|
| 255 | 255 | $capFile = DEPLOYNAUT_CAPFILE; |
| 256 | 256 | } else { |
| 257 | 257 | $capFile = ASSETS_PATH . '/Capfile'; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | file_put_contents($capFile, $cap); |
| 260 | 260 | |
| 261 | 261 | $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
| 262 | - foreach ($args as $argName => $argVal) { |
|
| 262 | + foreach($args as $argName => $argVal) { |
|
| 263 | 263 | $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -298,13 +298,13 @@ discard block |
||
| 298 | 298 | $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql'; |
| 299 | 299 | |
| 300 | 300 | // Backup database |
| 301 | - if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 301 | + if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 302 | 302 | $log->write(sprintf('Backup of database from "%s" started', $name)); |
| 303 | 303 | $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log); |
| 304 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 304 | + $command->run(function($type, $buffer) use ($log) { |
|
| 305 | 305 | $log->write($buffer); |
| 306 | 306 | }); |
| 307 | - if (!$command->isSuccessful()) { |
|
| 307 | + if(!$command->isSuccessful()) { |
|
| 308 | 308 | $this->extend('dataTransferFailure', $environment, $log); |
| 309 | 309 | throw new RuntimeException($command->getErrorOutput()); |
| 310 | 310 | } |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Backup assets |
| 315 | - if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 315 | + if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 316 | 316 | $log->write(sprintf('Backup of assets from "%s" started', $name)); |
| 317 | 317 | $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log); |
| 318 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 318 | + $command->run(function($type, $buffer) use ($log) { |
|
| 319 | 319 | $log->write($buffer); |
| 320 | 320 | }); |
| 321 | - if (!$command->isSuccessful()) { |
|
| 321 | + if(!$command->isSuccessful()) { |
|
| 322 | 322 | $this->extend('dataTransferFailure', $environment, $log); |
| 323 | 323 | throw new RuntimeException($command->getErrorOutput()); |
| 324 | 324 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | try { |
| 332 | 332 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
| 333 | 333 | $dataArchive->setArchiveFromFiles($filepathBase); |
| 334 | - } catch (Exception $e) { |
|
| 334 | + } catch(Exception $e) { |
|
| 335 | 335 | $log->write($e->getMessage()); |
| 336 | 336 | throw new RuntimeException($e->getMessage()); |
| 337 | 337 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | // e.g. when just an assets backup has been requested and no database.sql exists. |
| 342 | 342 | $process = new Process(sprintf('rm -rf %s/assets && rm -f %s', $filepathBase, $databasePath)); |
| 343 | 343 | $process->run(); |
| 344 | - if (!$process->isSuccessful()) { |
|
| 344 | + if(!$process->isSuccessful()) { |
|
| 345 | 345 | $log->write('Could not delete temporary files'); |
| 346 | 346 | throw new RuntimeException($process->getErrorOutput()); |
| 347 | 347 | } |
@@ -358,10 +358,10 @@ discard block |
||
| 358 | 358 | { |
| 359 | 359 | $name = $environment->getFullName(); |
| 360 | 360 | $command = $this->getCommand('deploy:migrate', 'web', $environment, null, $log); |
| 361 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 361 | + $command->run(function($type, $buffer) use ($log) { |
|
| 362 | 362 | $log->write($buffer); |
| 363 | 363 | }); |
| 364 | - if (!$command->isSuccessful()) { |
|
| 364 | + if(!$command->isSuccessful()) { |
|
| 365 | 365 | $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput())); |
| 366 | 366 | throw new RuntimeException($command->getErrorOutput()); |
| 367 | 367 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | // Rollback cleanup. |
| 385 | 385 | $self = $this; |
| 386 | - $cleanupFn = function () use ($self, $workingDir, $environment, $log) { |
|
| 386 | + $cleanupFn = function() use ($self, $workingDir, $environment, $log) { |
|
| 387 | 387 | // Rebuild makes sense even if failed - maybe we can at least partly recover. |
| 388 | 388 | $self->rebuild($environment, $log); |
| 389 | 389 | $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
@@ -391,14 +391,14 @@ discard block |
||
| 391 | 391 | }; |
| 392 | 392 | |
| 393 | 393 | // Restore database into target environment |
| 394 | - if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 394 | + if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 395 | 395 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
| 396 | 396 | $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
| 397 | 397 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
| 398 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 398 | + $command->run(function($type, $buffer) use ($log) { |
|
| 399 | 399 | $log->write($buffer); |
| 400 | 400 | }); |
| 401 | - if (!$command->isSuccessful()) { |
|
| 401 | + if(!$command->isSuccessful()) { |
|
| 402 | 402 | $cleanupFn(); |
| 403 | 403 | $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 404 | 404 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -408,14 +408,14 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Restore assets into target environment |
| 411 | - if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 411 | + if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 412 | 412 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
| 413 | 413 | $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
| 414 | 414 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
| 415 | - $command->run(function ($type, $buffer) use ($log) { |
|
| 415 | + $command->run(function($type, $buffer) use ($log) { |
|
| 416 | 416 | $log->write($buffer); |
| 417 | 417 | }); |
| 418 | - if (!$command->isSuccessful()) { |
|
| 418 | + if(!$command->isSuccessful()) { |
|
| 419 | 419 | $cleanupFn(); |
| 420 | 420 | $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 421 | 421 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | $log->write("Well, that was a waste of time"); |
| 57 | 57 | |
| 58 | 58 | // Once the deployment has run it's necessary to update the maintenance page status |
| 59 | - if (!empty($options['leaveMaintenancePage'])) { |
|
| 59 | + if(!empty($options['leaveMaintenancePage'])) { |
|
| 60 | 60 | $this->enableMaintenance($environment, $log, $project); |
| 61 | 61 | } else { |
| 62 | 62 | // Remove maintenance page if we want it to |
@@ -54,14 +54,14 @@ |
||
| 54 | 54 | public function getPackageFilename($identifier, $sha, $repositoryDir, DeploynautLogFile $log) |
| 55 | 55 | { |
| 56 | 56 | // Fetch through the cache |
| 57 | - if ($this->cache) { |
|
| 57 | + if($this->cache) { |
|
| 58 | 58 | $identifier .= '-' . get_class($this) . '-' . $this->getIdentifier(); |
| 59 | 59 | return $this->cache->getPackageFilename($this, $identifier, $sha, $repositoryDir, $log); |
| 60 | 60 | |
| 61 | 61 | // Default, cacheless implementation |
| 62 | 62 | } else { |
| 63 | 63 | $filename = TEMP_FOLDER . '/' . $sha . '.tar.gz'; |
| 64 | - if ($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
| 64 | + if($this->generatePackage($sha, $repositoryDir, $filename, $log)) { |
|
| 65 | 65 | return $filename; |
| 66 | 66 | } |
| 67 | 67 | } |