@@ -75,6 +75,7 @@ discard block  | 
                                                    ||
| 75 | 75 | }  | 
                                                        
| 76 | 76 | |
| 77 | 77 | /**  | 
                                                        
| 78 | + * @param string $code  | 
                                                        |
| 78 | 79 | */  | 
                                                        
| 79 | 80 |  	public function setActionCode($code) { | 
                                                        
| 80 | 81 | $this->actionCode = $code;  | 
                                                        
@@ -89,6 +90,7 @@ discard block  | 
                                                    ||
| 89 | 90 | |
| 90 | 91 | /**  | 
                                                        
| 91 | 92 | * @param int  | 
                                                        
| 93 | + * @param string $seconds  | 
                                                        |
| 92 | 94 | */  | 
                                                        
| 93 | 95 |  	public function setEstimatedTime($seconds) { | 
                                                        
| 94 | 96 | $this->estimatedTime = $seconds;  | 
                                                        
@@ -110,8 +110,12 @@  | 
                                                    ||
| 110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly.  | 
                                                        
| 111 | 111 | // This means there is no diference between an empty string and a null  | 
                                                        
| 112 | 112 | // but "0" is considered to be non-empty.  | 
                                                        
| 113 | - if(empty($from) && !strlen($from)) $from = '-';  | 
                                                        |
| 114 | - if(empty($to) && !strlen($to)) $to = '-';  | 
                                                        |
| 113 | +		if(empty($from) && !strlen($from)) { | 
                                                        |
| 114 | + $from = '-';  | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | +		if(empty($to) && !strlen($to)) { | 
                                                        |
| 117 | + $to = '-';  | 
                                                        |
| 118 | + }  | 
                                                        |
| 115 | 119 | |
| 116 | 120 | return $this->changes[$title] = array(  | 
                                                        
| 117 | 121 | 'from' => $from,  | 
                                                        
@@ -110,8 +110,8 @@ discard block  | 
                                                    ||
| 110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly.  | 
                                                        
| 111 | 111 | // This means there is no diference between an empty string and a null  | 
                                                        
| 112 | 112 | // but "0" is considered to be non-empty.  | 
                                                        
| 113 | - if(empty($from) && !strlen($from)) $from = '-';  | 
                                                        |
| 114 | - if(empty($to) && !strlen($to)) $to = '-';  | 
                                                        |
| 113 | + if (empty($from) && !strlen($from)) $from = '-';  | 
                                                        |
| 114 | + if (empty($to) && !strlen($to)) $to = '-';  | 
                                                        |
| 115 | 115 | |
| 116 | 116 | return $this->changes[$title] = array(  | 
                                                        
| 117 | 117 | 'from' => $from,  | 
                                                        
@@ -170,7 +170,7 @@ discard block  | 
                                                    ||
| 170 | 170 | */  | 
                                                        
| 171 | 171 |  	public function getChange($key) { | 
                                                        
| 172 | 172 | $changes = $this->getChanges();  | 
                                                        
| 173 | -		if(array_key_exists($key, $changes)) { | 
                                                        |
| 173 | +		if (array_key_exists($key, $changes)) { | 
                                                        |
| 174 | 174 | return new ArrayData($changes[$key]);  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | return null;  | 
                                                        
@@ -189,7 +189,7 @@ discard block  | 
                                                    ||
| 189 | 189 | * @return string|null  | 
                                                        
| 190 | 190 | */  | 
                                                        
| 191 | 191 |  	public function getOption($option) { | 
                                                        
| 192 | -		if(!empty($this->options[$option])) { | 
                                                        |
| 192 | +		if (!empty($this->options[$option])) { | 
                                                        |
| 193 | 193 | return $this->options[$option];  | 
                                                        
| 194 | 194 | }  | 
                                                        
| 195 | 195 | }  | 
                                                        
@@ -230,7 +230,7 @@ discard block  | 
                                                    ||
| 230 | 230 | DeploymentStrategy::WARNING_CODE => 1,  | 
                                                        
| 231 | 231 | DeploymentStrategy::ERROR_CODE => 2  | 
                                                        
| 232 | 232 | ];  | 
                                                        
| 233 | -		if($map[$current] < $map[$code]) { | 
                                                        |
| 233 | +		if ($map[$current] < $map[$code]) { | 
                                                        |
| 234 | 234 | $this->setValidationCode($code);  | 
                                                        
| 235 | 235 | }  | 
                                                        
| 236 | 236 | }  | 
                                                        
@@ -259,7 +259,7 @@ discard block  | 
                                                    ||
| 259 | 259 | );  | 
                                                        
| 260 | 260 | |
| 261 | 261 | $output = array();  | 
                                                        
| 262 | -		foreach($fields as $field) { | 
                                                        |
| 262 | +		foreach ($fields as $field) { | 
                                                        |
| 263 | 263 | $output[$field] = $this->$field;  | 
                                                        
| 264 | 264 | }  | 
                                                        
| 265 | 265 | return $output;  | 
                                                        
@@ -300,8 +300,8 @@ discard block  | 
                                                    ||
| 300 | 300 | 'messages'  | 
                                                        
| 301 | 301 | );  | 
                                                        
| 302 | 302 | |
| 303 | -		foreach($fields as $field) { | 
                                                        |
| 304 | -			if(!empty($data[$field])) { | 
                                                        |
| 303 | +		foreach ($fields as $field) { | 
                                                        |
| 304 | +			if (!empty($data[$field])) { | 
                                                        |
| 305 | 305 | $this->$field = $data[$field];  | 
                                                        
| 306 | 306 | }  | 
                                                        
| 307 | 307 | }  | 
                                                        
@@ -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  | 
                                                        
@@ -774,7 +774,7 @@ discard block  | 
                                                    ||
| 774 | 774 |  				->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members) | 
                                                        
| 775 | 775 |  				->setTitle('Who can upload?') | 
                                                        
| 776 | 776 | ->setDescription(  | 
                                                        
| 777 | - 'Users who can upload archives linked to this environment into Deploynaut.<br />' .  | 
                                                        |
| 777 | + 'Users who can upload archives linked to this environment into Deploynaut.<br />'.  | 
                                                        |
| 778 | 778 | 'Linking them to an environment allows limiting download permissions (see below).'  | 
                                                        
| 779 | 779 | ),  | 
                                                        
| 780 | 780 | |
@@ -821,7 +821,7 @@ discard block  | 
                                                    ||
| 821 | 821 | // Add actions  | 
                                                        
| 822 | 822 |  		$action = new FormAction('check', 'Check Connection'); | 
                                                        
| 823 | 823 | $action->setUseButtonTag(true);  | 
                                                        
| 824 | - $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping';  | 
                                                        |
| 824 | + $dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping';  | 
                                                        |
| 825 | 825 |  		$action->setAttribute('data-url', $dataURL); | 
                                                        
| 826 | 826 | $fields->insertBefore($action, 'Name');  | 
                                                        
| 827 | 827 | |
@@ -834,8 +834,8 @@ discard block  | 
                                                    ||
| 834 | 834 | */  | 
                                                        
| 835 | 835 |  	public function onBeforeWrite() { | 
                                                        
| 836 | 836 | parent::onBeforeWrite();  | 
                                                        
| 837 | -		if ($this->Name && $this->Name . '.rb' != $this->Filename) { | 
                                                        |
| 838 | - $this->Filename = $this->Name . '.rb';  | 
                                                        |
| 837 | +		if ($this->Name && $this->Name.'.rb' != $this->Filename) { | 
                                                        |
| 838 | + $this->Filename = $this->Name.'.rb';  | 
                                                        |
| 839 | 839 | }  | 
                                                        
| 840 | 840 | $this->checkEnvironmentPath();  | 
                                                        
| 841 | 841 | $this->writeConfigFile();  | 
                                                        
@@ -885,7 +885,7 @@ discard block  | 
                                                    ||
| 885 | 885 |  		if (!$this->Filename) { | 
                                                        
| 886 | 886 | return '';  | 
                                                        
| 887 | 887 | }  | 
                                                        
| 888 | - return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename;  | 
                                                        |
| 888 | + return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename;  | 
                                                        |
| 889 | 889 | }  | 
                                                        
| 890 | 890 | |
| 891 | 891 | /**  | 
                                                        
@@ -1039,7 +1039,7 @@ discard block  | 
                                                    ||
| 1039 | 1039 | && $this->Filename  | 
                                                        
| 1040 | 1040 | && $this->CreateEnvConfig  | 
                                                        
| 1041 | 1041 |  		) { | 
                                                        
| 1042 | - $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template';  | 
                                                        |
| 1042 | + $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template';  | 
                                                        |
| 1043 | 1043 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile));  | 
                                                        
| 1044 | 1044 |  		} else if ($this->envFileExists() && $this->DeployConfig) { | 
                                                        
| 1045 | 1045 | file_put_contents($this->getConfigFilename(), $this->DeployConfig);  | 
                                                        
@@ -961,7 +961,7 @@  | 
                                                    ||
| 961 | 961 | * @param array $data  | 
                                                        
| 962 | 962 | * @param Form $form  | 
                                                        
| 963 | 963 | *  | 
                                                        
| 964 | - * @return bool|HTMLText|SS_HTTPResponse  | 
                                                        |
| 964 | + * @return SS_HTTPResponse|null  | 
                                                        |
| 965 | 965 | */  | 
                                                        
| 966 | 966 |  	public function doCreateEnvironment($data, Form $form) { | 
                                                        
| 967 | 967 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS);  | 
                                                        
@@ -179,7 +179,7 @@ discard block  | 
                                                    ||
| 179 | 179 |  		Requirements::javascript('deploynaut/javascript/material.js'); | 
                                                        
| 180 | 180 | |
| 181 | 181 | // Load the buildable dependencies only if not loaded centrally.  | 
                                                        
| 182 | -		if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { | 
                                                        |
| 182 | +		if (!is_dir(BASE_PATH.DIRECTORY_SEPARATOR.'static')) { | 
                                                        |
| 183 | 183 |  			if (\Director::isDev()) { | 
                                                        
| 184 | 184 |  				\Requirements::javascript('deploynaut/static/bundle-debug.js'); | 
                                                        
| 185 | 185 |  			} else { | 
                                                        
@@ -243,7 +243,7 @@ discard block  | 
                                                    ||
| 243 | 243 | }  | 
                                                        
| 244 | 244 | |
| 245 | 245 | // Block framework jquery  | 
                                                        
| 246 | - Requirements::block(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');  | 
                                                        |
| 246 | + Requirements::block(FRAMEWORK_DIR.'/thirdparty/jquery/jquery.js');  | 
                                                        |
| 247 | 247 | |
| 248 | 248 | self::include_requirements();  | 
                                                        
| 249 | 249 | }  | 
                                                        
@@ -262,7 +262,7 @@ discard block  | 
                                                    ||
| 262 | 262 | * @return \SS_HTTPResponse  | 
                                                        
| 263 | 263 | */  | 
                                                        
| 264 | 264 |  	public function index(SS_HTTPRequest $request) { | 
                                                        
| 265 | - return $this->redirect($this->Link() . 'projects/');  | 
                                                        |
| 265 | + return $this->redirect($this->Link().'projects/');  | 
                                                        |
| 266 | 266 | }  | 
                                                        
| 267 | 267 | |
| 268 | 268 | /**  | 
                                                        
@@ -390,7 +390,7 @@ discard block  | 
                                                    ||
| 390 | 390 | // Framing an environment as a "group of people with download access"  | 
                                                        
| 391 | 391 | // makes more sense to the user here, while still allowing us to enforce  | 
                                                        
| 392 | 392 | // environment specific restrictions on downloading the file later on.  | 
                                                        
| 393 | -		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { | 
                                                        |
| 393 | +		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) { | 
                                                        |
| 394 | 394 | return $item->canUploadArchive();  | 
                                                        
| 395 | 395 | });  | 
                                                        
| 396 | 396 | $envsMap = [];  | 
                                                        
@@ -422,7 +422,7 @@ discard block  | 
                                                    ||
| 422 | 422 | $form->disableSecurityToken();  | 
                                                        
| 423 | 423 |  		$form->addExtraClass('fields-wide'); | 
                                                        
| 424 | 424 | // Tweak the action so it plays well with our fake URL structure.  | 
                                                        
| 425 | - $form->setFormAction($project->Link() . '/UploadSnapshotForm');  | 
                                                        |
| 425 | + $form->setFormAction($project->Link().'/UploadSnapshotForm');  | 
                                                        |
| 426 | 426 | |
| 427 | 427 | return $form;  | 
                                                        
| 428 | 428 | }  | 
                                                        
@@ -443,7 +443,7 @@ discard block  | 
                                                    ||
| 443 | 443 | }  | 
                                                        
| 444 | 444 | |
| 445 | 445 | $validEnvs = $project->DNEnvironmentList()  | 
                                                        
| 446 | -			->filterByCallback(function ($item) { | 
                                                        |
| 446 | +			->filterByCallback(function($item) { | 
                                                        |
| 447 | 447 | return $item->canUploadArchive();  | 
                                                        
| 448 | 448 | });  | 
                                                        
| 449 | 449 | |
@@ -472,9 +472,9 @@ discard block  | 
                                                    ||
| 472 | 472 | $dataArchive->DataTransfers()->add($dataTransfer);  | 
                                                        
| 473 | 473 | $form->saveInto($dataArchive);  | 
                                                        
| 474 | 474 | $dataArchive->write();  | 
                                                        
| 475 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID;  | 
                                                        |
| 475 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID;  | 
                                                        |
| 476 | 476 | |
| 477 | -		$cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) { | 
                                                        |
| 477 | +		$cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) { | 
                                                        |
| 478 | 478 |  			$process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); | 
                                                        
| 479 | 479 | $process->setTimeout(120);  | 
                                                        
| 480 | 480 | $process->run();  | 
                                                        
@@ -548,7 +548,7 @@ discard block  | 
                                                    ||
| 548 | 548 | // Framing an environment as a "group of people with download access"  | 
                                                        
| 549 | 549 | // makes more sense to the user here, while still allowing us to enforce  | 
                                                        
| 550 | 550 | // environment specific restrictions on downloading the file later on.  | 
                                                        
| 551 | -		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { | 
                                                        |
| 551 | +		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) { | 
                                                        |
| 552 | 552 | return $item->canUploadArchive();  | 
                                                        
| 553 | 553 | });  | 
                                                        
| 554 | 554 | $envsMap = [];  | 
                                                        
@@ -574,7 +574,7 @@ discard block  | 
                                                    ||
| 574 | 574 | $form->disableSecurityToken();  | 
                                                        
| 575 | 575 |  		$form->addExtraClass('fields-wide'); | 
                                                        
| 576 | 576 | // Tweak the action so it plays well with our fake URL structure.  | 
                                                        
| 577 | - $form->setFormAction($project->Link() . '/PostSnapshotForm');  | 
                                                        |
| 577 | + $form->setFormAction($project->Link().'/PostSnapshotForm');  | 
                                                        |
| 578 | 578 | |
| 579 | 579 | return $form;  | 
                                                        
| 580 | 580 | }  | 
                                                        
@@ -593,7 +593,7 @@ discard block  | 
                                                    ||
| 593 | 593 | return $this->project404Response();  | 
                                                        
| 594 | 594 | }  | 
                                                        
| 595 | 595 | |
| 596 | -		$validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) { | 
                                                        |
| 596 | +		$validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) { | 
                                                        |
| 597 | 597 | return $item->canUploadArchive();  | 
                                                        
| 598 | 598 | });  | 
                                                        
| 599 | 599 | |
@@ -713,7 +713,7 @@ discard block  | 
                                                    ||
| 713 | 713 |  		$branchName = $request->getVar('name'); | 
                                                        
| 714 | 714 | $branch = $project->DNBranchList()->byName($branchName);  | 
                                                        
| 715 | 715 |  		if (!$branch) { | 
                                                        
| 716 | -			return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404); | 
                                                        |
| 716 | +			return new SS_HTTPResponse("Branch '".Convert::raw2xml($branchName)."' not found.", 404); | 
                                                        |
| 717 | 717 | }  | 
                                                        
| 718 | 718 | |
| 719 | 719 | return $this->render([  | 
                                                        
@@ -850,7 +850,7 @@ discard block  | 
                                                    ||
| 850 | 850 | );  | 
                                                        
| 851 | 851 | |
| 852 | 852 | // Tweak the action so it plays well with our fake URL structure.  | 
                                                        
| 853 | - $form->setFormAction($project->Link() . '/CreateEnvironmentForm');  | 
                                                        |
| 853 | + $form->setFormAction($project->Link().'/CreateEnvironmentForm');  | 
                                                        |
| 854 | 854 | |
| 855 | 855 | return $form;  | 
                                                        
| 856 | 856 | }  | 
                                                        
@@ -883,7 +883,7 @@ discard block  | 
                                                    ||
| 883 | 883 | $job->write();  | 
                                                        
| 884 | 884 | $job->start();  | 
                                                        
| 885 | 885 | |
| 886 | -		return $this->redirect($project->Link('createenv') . '/' . $job->ID); | 
                                                        |
| 886 | +		return $this->redirect($project->Link('createenv').'/'.$job->ID); | 
                                                        |
| 887 | 887 | }  | 
                                                        
| 888 | 888 | |
| 889 | 889 | /**  | 
                                                        
@@ -1081,7 +1081,7 @@ discard block  | 
                                                    ||
| 1081 | 1081 | return $body;  | 
                                                        
| 1082 | 1082 | }  | 
                                                        
| 1083 | 1083 | |
| 1084 | - $form->setFormAction($this->getRequest()->getURL() . '/DeployForm');  | 
                                                        |
| 1084 | + $form->setFormAction($this->getRequest()->getURL().'/DeployForm');  | 
                                                        |
| 1085 | 1085 | return $form;  | 
                                                        
| 1086 | 1086 | }  | 
                                                        
| 1087 | 1087 | |
@@ -1347,7 +1347,7 @@ discard block  | 
                                                    ||
| 1347 | 1347 | $deployment->getMachine()->apply(DNDeployment::TR_QUEUE);  | 
                                                        
| 1348 | 1348 | |
| 1349 | 1349 | return json_encode([  | 
                                                        
| 1350 | - 'url' => Director::absoluteBaseURL() . $deployment->Link()  | 
                                                        |
| 1350 | + 'url' => Director::absoluteBaseURL().$deployment->Link()  | 
                                                        |
| 1351 | 1351 | ], JSON_PRETTY_PRINT);  | 
                                                        
| 1352 | 1352 | }  | 
                                                        
| 1353 | 1353 | |
@@ -1470,7 +1470,7 @@ discard block  | 
                                                    ||
| 1470 | 1470 | */  | 
                                                        
| 1471 | 1471 |  	public function getDataTransferForm(SS_HTTPRequest $request = null) { | 
                                                        
| 1472 | 1472 | // Performs canView permission check by limiting visible projects  | 
                                                        
| 1473 | -		$envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) { | 
                                                        |
| 1473 | +		$envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) { | 
                                                        |
| 1474 | 1474 | return $item->canBackup();  | 
                                                        
| 1475 | 1475 | });  | 
                                                        
| 1476 | 1476 | |
@@ -1480,7 +1480,7 @@ discard block  | 
                                                    ||
| 1480 | 1480 | |
| 1481 | 1481 | $items = [];  | 
                                                        
| 1482 | 1482 | $disabledEnvironments = [];  | 
                                                        
| 1483 | -		foreach($envs as $env) { | 
                                                        |
| 1483 | +		foreach ($envs as $env) { | 
                                                        |
| 1484 | 1484 | $items[$env->ID] = $env->Title;  | 
                                                        
| 1485 | 1485 |  			if ($env->CurrentBuild() === false) { | 
                                                        
| 1486 | 1486 |  				$items[$env->ID] = sprintf("%s - requires initial deployment", $env->Title); | 
                                                        
@@ -1488,7 +1488,7 @@ discard block  | 
                                                    ||
| 1488 | 1488 | }  | 
                                                        
| 1489 | 1489 | }  | 
                                                        
| 1490 | 1490 | |
| 1491 | -		$envsField =  DropdownField::create('EnvironmentID', 'Environment', $items) | 
                                                        |
| 1491 | +		$envsField = DropdownField::create('EnvironmentID', 'Environment', $items) | 
                                                        |
| 1492 | 1492 |  			->setEmptyString('Select an environment'); | 
                                                        
| 1493 | 1493 | $envsField->setDisabledItems($disabledEnvironments);  | 
                                                        
| 1494 | 1494 | |
@@ -1509,7 +1509,7 @@ discard block  | 
                                                    ||
| 1509 | 1509 | ),  | 
                                                        
| 1510 | 1510 | FieldList::create($formAction)  | 
                                                        
| 1511 | 1511 | );  | 
                                                        
| 1512 | - $form->setFormAction($this->getRequest()->getURL() . '/DataTransferForm');  | 
                                                        |
| 1512 | + $form->setFormAction($this->getRequest()->getURL().'/DataTransferForm');  | 
                                                        |
| 1513 | 1513 | |
| 1514 | 1514 | return $form;  | 
                                                        
| 1515 | 1515 | }  | 
                                                        
@@ -1535,12 +1535,12 @@ discard block  | 
                                                    ||
| 1535 | 1535 | // Validate direction.  | 
                                                        
| 1536 | 1536 |  		if ($data['Direction'] == 'get') { | 
                                                        
| 1537 | 1537 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList()  | 
                                                        
| 1538 | -				->filterByCallback(function ($item) { | 
                                                        |
| 1538 | +				->filterByCallback(function($item) { | 
                                                        |
| 1539 | 1539 | return $item->canBackup();  | 
                                                        
| 1540 | 1540 | });  | 
                                                        
| 1541 | 1541 |  		} else if ($data['Direction'] == 'push') { | 
                                                        
| 1542 | 1542 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList()  | 
                                                        
| 1543 | -				->filterByCallback(function ($item) { | 
                                                        |
| 1543 | +				->filterByCallback(function($item) { | 
                                                        |
| 1544 | 1544 | return $item->canRestore();  | 
                                                        
| 1545 | 1545 | });  | 
                                                        
| 1546 | 1546 |  		} else { | 
                                                        
@@ -1671,7 +1671,7 @@ discard block  | 
                                                    ||
| 1671 | 1671 | |
| 1672 | 1672 | // Performs canView permission check by limiting visible projects  | 
                                                        
| 1673 | 1673 | $project = $this->getCurrentProject();  | 
                                                        
| 1674 | -		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { | 
                                                        |
| 1674 | +		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) { | 
                                                        |
| 1675 | 1675 | return $item->canRestore();  | 
                                                        
| 1676 | 1676 | });  | 
                                                        
| 1677 | 1677 | |
@@ -1696,7 +1696,7 @@ discard block  | 
                                                    ||
| 1696 | 1696 | |
| 1697 | 1697 | $items = [];  | 
                                                        
| 1698 | 1698 | $disabledEnvironments = [];  | 
                                                        
| 1699 | -		foreach($envs as $env) { | 
                                                        |
| 1699 | +		foreach ($envs as $env) { | 
                                                        |
| 1700 | 1700 | $items[$env->ID] = $env->Title;  | 
                                                        
| 1701 | 1701 |  			if ($env->CurrentBuild() === false) { | 
                                                        
| 1702 | 1702 |  				$items[$env->ID] = sprintf("%s - requires initial deployment", $env->Title); | 
                                                        
@@ -1725,7 +1725,7 @@ discard block  | 
                                                    ||
| 1725 | 1725 | ),  | 
                                                        
| 1726 | 1726 | FieldList::create($formAction)  | 
                                                        
| 1727 | 1727 | );  | 
                                                        
| 1728 | - $form->setFormAction($project->Link() . '/DataTransferRestoreForm');  | 
                                                        |
| 1728 | + $form->setFormAction($project->Link().'/DataTransferRestoreForm');  | 
                                                        |
| 1729 | 1729 | |
| 1730 | 1730 | return $form;  | 
                                                        
| 1731 | 1731 | }  | 
                                                        
@@ -1823,7 +1823,7 @@ discard block  | 
                                                    ||
| 1823 | 1823 |  					->addExtraClass('btn') | 
                                                        
| 1824 | 1824 | )  | 
                                                        
| 1825 | 1825 | );  | 
                                                        
| 1826 | - $form->setFormAction($project->Link() . '/DeleteForm');  | 
                                                        |
| 1826 | + $form->setFormAction($project->Link().'/DeleteForm');  | 
                                                        |
| 1827 | 1827 | |
| 1828 | 1828 | return $form;  | 
                                                        
| 1829 | 1829 | }  | 
                                                        
@@ -1929,7 +1929,7 @@ discard block  | 
                                                    ||
| 1929 | 1929 |  					->addExtraClass('btn') | 
                                                        
| 1930 | 1930 | )  | 
                                                        
| 1931 | 1931 | );  | 
                                                        
| 1932 | - $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm');  | 
                                                        |
| 1932 | + $form->setFormAction($this->getCurrentProject()->Link().'/MoveForm');  | 
                                                        |
| 1933 | 1933 | |
| 1934 | 1934 | return $form;  | 
                                                        
| 1935 | 1935 | }  | 
                                                        
@@ -2190,7 +2190,7 @@ discard block  | 
                                                    ||
| 2190 | 2190 | $transfers = DNDataTransfer::get()  | 
                                                        
| 2191 | 2191 |  			->filter('EnvironmentID', $environments) | 
                                                        
| 2192 | 2192 | ->filterByCallback(  | 
                                                        
| 2193 | -				function ($record) { | 
                                                        |
| 2193 | +				function($record) { | 
                                                        |
| 2194 | 2194 | return  | 
                                                        
| 2195 | 2195 | $record->Environment()->canRestore() || // Ensure member can perform an action on the transfers env  | 
                                                        
| 2196 | 2196 | $record->Environment()->canBackup() ||  | 
                                                        
@@ -2315,7 +2315,7 @@ discard block  | 
                                                    ||
| 2315 | 2315 | */  | 
                                                        
| 2316 | 2316 |  	protected function project404Response() { | 
                                                        
| 2317 | 2317 | return new SS_HTTPResponse(  | 
                                                        
| 2318 | -			"Project '" . Convert::raw2xml($this->getRequest()->param('Project')) . "' not found.", | 
                                                        |
| 2318 | +			"Project '".Convert::raw2xml($this->getRequest()->param('Project'))."' not found.", | 
                                                        |
| 2319 | 2319 | 404  | 
                                                        
| 2320 | 2320 | );  | 
                                                        
| 2321 | 2321 | }  | 
                                                        
@@ -2325,7 +2325,7 @@ discard block  | 
                                                    ||
| 2325 | 2325 | */  | 
                                                        
| 2326 | 2326 |  	protected function environment404Response() { | 
                                                        
| 2327 | 2327 |  		$envName = Convert::raw2xml($this->getRequest()->param('Environment')); | 
                                                        
| 2328 | -		return new SS_HTTPResponse("Environment '" . $envName . "' not found.", 404); | 
                                                        |
| 2328 | +		return new SS_HTTPResponse("Environment '".$envName."' not found.", 404); | 
                                                        |
| 2329 | 2329 | }  | 
                                                        
| 2330 | 2330 | |
| 2331 | 2331 | /**  | 
                                                        
@@ -31,7 +31,7 @@  | 
                                                    ||
| 31 | 31 | * Do the actual job by calling the appropiate backend  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | 33 |  	public function perform() { | 
                                                        
| 34 | - echo "[-] PingJob starting" . PHP_EOL;  | 
                                                        |
| 34 | + echo "[-] PingJob starting".PHP_EOL;  | 
                                                        |
| 35 | 35 | $log = new DeploynautLogFile($this->args['logfile']);  | 
                                                        
| 36 | 36 | |
| 37 | 37 | $ping = DNPing::get()->byID($this->args['pingID']);  | 
                                                        
@@ -205,12 +205,16 @@  | 
                                                    ||
| 205 | 205 | */  | 
                                                        
| 206 | 206 |  	public function getFullDeployMessages() { | 
                                                        
| 207 | 207 | $strategy = $this->getDeploymentStrategy();  | 
                                                        
| 208 | - if ($strategy->getActionCode()!=='full') return null;  | 
                                                        |
| 208 | +		if ($strategy->getActionCode()!=='full') { | 
                                                        |
| 209 | + return null;  | 
                                                        |
| 210 | + }  | 
                                                        |
| 209 | 211 | |
| 210 | 212 | $changes = $strategy->getChangesModificationNeeded();  | 
                                                        
| 211 | 213 | $messages = [];  | 
                                                        
| 212 | 214 |  		foreach ($changes as $change => $details) { | 
                                                        
| 213 | - if ($change==='Code version') continue;  | 
                                                        |
| 215 | +			if ($change==='Code version') { | 
                                                        |
| 216 | + continue;  | 
                                                        |
| 217 | + }  | 
                                                        |
| 214 | 218 | |
| 215 | 219 | $messages[] = [  | 
                                                        
| 216 | 220 | 'Flag' => sprintf(  | 
                                                        
@@ -82,6 +82,9 @@  | 
                                                    ||
| 82 | 82 | 'Deployer.Name' => 'Deployer'  | 
                                                        
| 83 | 83 | );  | 
                                                        
| 84 | 84 | |
| 85 | + /**  | 
                                                        |
| 86 | + * @param false|string $token  | 
                                                        |
| 87 | + */  | 
                                                        |
| 85 | 88 |  	public function setResqueToken($token) { | 
                                                        
| 86 | 89 | $this->ResqueToken = $token;  | 
                                                        
| 87 | 90 | }  | 
                                                        
@@ -108,7 +108,7 @@ discard block  | 
                                                    ||
| 108 | 108 | }  | 
                                                        
| 109 | 109 | |
| 110 | 110 |  	public function LogLink() { | 
                                                        
| 111 | - return $this->Link() . '/log';  | 
                                                        |
| 111 | + return $this->Link().'/log';  | 
                                                        |
| 112 | 112 | }  | 
                                                        
| 113 | 113 | |
| 114 | 114 |  	public function canView($member = null) { | 
                                                        
@@ -154,7 +154,7 @@ discard block  | 
                                                    ||
| 154 | 154 | * @return \Gitonomy\Git\Repository|null  | 
                                                        
| 155 | 155 | */  | 
                                                        
| 156 | 156 |  	public function getRepository() { | 
                                                        
| 157 | -		if(!$this->SHA) { | 
                                                        |
| 157 | +		if (!$this->SHA) { | 
                                                        |
| 158 | 158 | return null;  | 
                                                        
| 159 | 159 | }  | 
                                                        
| 160 | 160 | return $this->Environment()->Project()->getRepository();  | 
                                                        
@@ -167,10 +167,10 @@ discard block  | 
                                                    ||
| 167 | 167 | */  | 
                                                        
| 168 | 168 |  	public function getCommit() { | 
                                                        
| 169 | 169 | $repo = $this->getRepository();  | 
                                                        
| 170 | -		if($repo) { | 
                                                        |
| 170 | +		if ($repo) { | 
                                                        |
| 171 | 171 |  			try { | 
                                                        
| 172 | 172 | return $this->Environment()->getCommit($this->SHA);  | 
                                                        
| 173 | -			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { | 
                                                        |
| 173 | +			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { | 
                                                        |
| 174 | 174 | return null;  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | }  | 
                                                        
@@ -195,7 +195,7 @@ discard block  | 
                                                    ||
| 195 | 195 |  		if (!$interface) { | 
                                                        
| 196 | 196 | return null;  | 
                                                        
| 197 | 197 | }  | 
                                                        
| 198 | - return $interface->CommitURL . '/' . $this->SHA;  | 
                                                        |
| 198 | + return $interface->CommitURL.'/'.$this->SHA;  | 
                                                        |
| 199 | 199 | }  | 
                                                        
| 200 | 200 | |
| 201 | 201 | /**  | 
                                                        
@@ -205,10 +205,10 @@ discard block  | 
                                                    ||
| 205 | 205 | */  | 
                                                        
| 206 | 206 |  	public function getCommitMessage() { | 
                                                        
| 207 | 207 | $commit = $this->getCommit();  | 
                                                        
| 208 | -		if($commit) { | 
                                                        |
| 208 | +		if ($commit) { | 
                                                        |
| 209 | 209 |  			try { | 
                                                        
| 210 | 210 | return Convert::raw2xml($this->Environment()->getCommitMessage($commit));  | 
                                                        
| 211 | -			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { | 
                                                        |
| 211 | +			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { | 
                                                        |
| 212 | 212 | return null;  | 
                                                        
| 213 | 213 | }  | 
                                                        
| 214 | 214 | }  | 
                                                        
@@ -225,7 +225,7 @@ discard block  | 
                                                    ||
| 225 | 225 | $this->Environment()->getCommitTags($commit);  | 
                                                        
| 226 | 226 | $returnTags = [];  | 
                                                        
| 227 | 227 |  		if (!empty($tags)) { | 
                                                        
| 228 | -			foreach($tags as $tag) { | 
                                                        |
| 228 | +			foreach ($tags as $tag) { | 
                                                        |
| 229 | 229 |  				$field = Varchar::create('Tag', '255'); | 
                                                        
| 230 | 230 | $field->setValue($tag->getName());  | 
                                                        
| 231 | 231 | $returnTags[] = $field;  | 
                                                        
@@ -242,12 +242,12 @@ discard block  | 
                                                    ||
| 242 | 242 | */  | 
                                                        
| 243 | 243 |  	public function getFullDeployMessages() { | 
                                                        
| 244 | 244 | $strategy = $this->getDeploymentStrategy();  | 
                                                        
| 245 | - if ($strategy->getActionCode()!=='full') return null;  | 
                                                        |
| 245 | + if ($strategy->getActionCode() !== 'full') return null;  | 
                                                        |
| 246 | 246 | |
| 247 | 247 | $changes = $strategy->getChangesModificationNeeded();  | 
                                                        
| 248 | 248 | $messages = [];  | 
                                                        
| 249 | 249 |  		foreach ($changes as $change => $details) { | 
                                                        
| 250 | - if ($change==='Code version') continue;  | 
                                                        |
| 250 | + if ($change === 'Code version') continue;  | 
                                                        |
| 251 | 251 | |
| 252 | 252 | $messages[] = [  | 
                                                        
| 253 | 253 | 'Flag' => sprintf(  | 
                                                        
@@ -275,7 +275,7 @@ discard block  | 
                                                    ||
| 275 | 275 | */  | 
                                                        
| 276 | 276 |  	public function getTag() { | 
                                                        
| 277 | 277 | $tags = $this->getTags();  | 
                                                        
| 278 | -		if($tags->count() > 0) { | 
                                                        |
| 278 | +		if ($tags->count() > 0) { | 
                                                        |
| 279 | 279 | return $tags->last();  | 
                                                        
| 280 | 280 | }  | 
                                                        
| 281 | 281 | return null;  | 
                                                        
@@ -300,7 +300,7 @@ discard block  | 
                                                    ||
| 300 | 300 |  	public function getChanges() { | 
                                                        
| 301 | 301 | $list = new ArrayList();  | 
                                                        
| 302 | 302 | $strategy = $this->getDeploymentStrategy();  | 
                                                        
| 303 | -		foreach($strategy->getChanges() as $name => $change) { | 
                                                        |
| 303 | +		foreach ($strategy->getChanges() as $name => $change) { | 
                                                        |
| 304 | 304 | $changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null;  | 
                                                        
| 305 | 305 | $description = isset($change['description']) ? $change['description'] : '';  | 
                                                        
| 306 | 306 | $compareUrl = null;  | 
                                                        
@@ -350,11 +350,11 @@ discard block  | 
                                                    ||
| 350 | 350 | // Make sure we use the SHA as it was written into this DNDeployment.  | 
                                                        
| 351 | 351 | $args['sha'] = $this->SHA;  | 
                                                        
| 352 | 352 | |
| 353 | -		if(!$this->DeployerID) { | 
                                                        |
| 353 | +		if (!$this->DeployerID) { | 
                                                        |
| 354 | 354 | $this->DeployerID = Member::currentUserID();  | 
                                                        
| 355 | 355 | }  | 
                                                        
| 356 | 356 | |
| 357 | -		if($this->DeployerID) { | 
                                                        |
| 357 | +		if ($this->DeployerID) { | 
                                                        |
| 358 | 358 | $deployer = $this->Deployer();  | 
                                                        
| 359 | 359 | $message = sprintf(  | 
                                                        
| 360 | 360 | 'Deploy to %s initiated by %s (%s), with IP address %s',  | 
                                                        
@@ -73,7 +73,7 @@ discard block  | 
                                                    ||
| 73 | 73 | substr($sha, 0, 8),  | 
                                                        
| 74 | 74 | $branch->LastUpdated()->TimeDiff()  | 
                                                        
| 75 | 75 | );  | 
                                                        
| 76 | - $branches[$sha . '-' . $name] = $branchValue;  | 
                                                        |
| 76 | + $branches[$sha.'-'.$name] = $branchValue;  | 
                                                        |
| 77 | 77 | }  | 
                                                        
| 78 | 78 | |
| 79 | 79 | // Tags  | 
                                                        
@@ -86,7 +86,7 @@ discard block  | 
                                                    ||
| 86 | 86 | substr($sha, 0, 8),  | 
                                                        
| 87 | 87 | $branch->LastUpdated()->TimeDiff()  | 
                                                        
| 88 | 88 | );  | 
                                                        
| 89 | - $tags[$sha . '-' . $tag] = $tagValue;  | 
                                                        |
| 89 | + $tags[$sha.'-'.$tag] = $tagValue;  | 
                                                        |
| 90 | 90 | }  | 
                                                        
| 91 | 91 | $tags = array_reverse($tags);  | 
                                                        
| 92 | 92 | |
@@ -58,7 +58,9 @@  | 
                                                    ||
| 58 | 58 | |
| 59 | 59 |  	protected function addHandlers($machine) { | 
                                                        
| 60 | 60 | $class = get_class($machine->getObject());  | 
                                                        
| 61 | - if (empty($this->config()->handlers[$class])) return;  | 
                                                        |
| 61 | +		if (empty($this->config()->handlers[$class])) { | 
                                                        |
| 62 | + return;  | 
                                                        |
| 63 | + }  | 
                                                        |
| 62 | 64 | |
| 63 | 65 | $transitions = $this->config()->handlers[$class];  | 
                                                        
| 64 | 66 |  		foreach ($transitions as $transName => $handlers) { | 
                                                        
@@ -46,7 +46,7 @@  | 
                                                    ||
| 46 | 46 | *  | 
                                                        
| 47 | 47 | * @param \SS_HTTPRequest $request  | 
                                                        
| 48 | 48 | *  | 
                                                        
| 49 | - * @return \HTMLText|\SS_HTTPResponse  | 
                                                        |
| 49 | + * @return SS_HTTPResponse|null  | 
                                                        |
| 50 | 50 | */  | 
                                                        
| 51 | 51 |  	public function index(\SS_HTTPRequest $request) { | 
                                                        
| 52 | 52 | return $this->redirect(\Controller::join_links($this->Link(), 'history'), 302);  | 
                                                        
@@ -47,7 +47,7 @@ discard block  | 
                                                    ||
| 47 | 47 | *  | 
                                                        
| 48 | 48 | * @param \SS_HTTPRequest $request  | 
                                                        
| 49 | 49 | *  | 
                                                        
| 50 | - * @return \HTMLText|\SS_HTTPResponse  | 
                                                        |
| 50 | + * @return SS_HTTPResponse|null  | 
                                                        |
| 51 | 51 | */  | 
                                                        
| 52 | 52 |  	public function index(\SS_HTTPRequest $request) { | 
                                                        
| 53 | 53 | return $this->redirect(\Controller::join_links($this->Link(), 'show'), 302);  | 
                                                        
@@ -72,7 +72,7 @@ discard block  | 
                                                    ||
| 72 | 72 | /**  | 
                                                        
| 73 | 73 | * @param SS_HTTPRequest $request  | 
                                                        
| 74 | 74 | *  | 
                                                        
| 75 | - * @return string  | 
                                                        |
| 75 | + * @return SS_HTTPResponse  | 
                                                        |
| 76 | 76 | */  | 
                                                        
| 77 | 77 |  	public function show(\SS_HTTPRequest $request) { | 
                                                        
| 78 | 78 | |
@@ -166,7 +166,7 @@ discard block  | 
                                                    ||
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | 168 | /**  | 
                                                        
| 169 | - * @param $project  | 
                                                        |
| 169 | + * @param DNProject $project  | 
                                                        |
| 170 | 170 | *  | 
                                                        
| 171 | 171 | * @return array  | 
                                                        
| 172 | 172 | */  | 
                                                        
@@ -182,7 +182,7 @@ discard block  | 
                                                    ||
| 182 | 182 | }  | 
                                                        
| 183 | 183 | |
| 184 | 184 | /**  | 
                                                        
| 185 | - * @param $project  | 
                                                        |
| 185 | + * @param DNProject $project  | 
                                                        |
| 186 | 186 | *  | 
                                                        
| 187 | 187 | * @return array  | 
                                                        
| 188 | 188 | */  | 
                                                        
@@ -198,7 +198,7 @@ discard block  | 
                                                    ||
| 198 | 198 | }  | 
                                                        
| 199 | 199 | |
| 200 | 200 | /**  | 
                                                        
| 201 | - * @param $project  | 
                                                        |
| 201 | + * @param DNProject $project  | 
                                                        |
| 202 | 202 | *  | 
                                                        
| 203 | 203 | * @return array  | 
                                                        
| 204 | 204 | */  | 
                                                        
@@ -133,7 +133,7 @@ discard block  | 
                                                    ||
| 133 | 133 |  	protected function getUpdateStatus($ID) { | 
                                                        
| 134 | 134 | $ping = DNGitFetch::get()->byID($ID);  | 
                                                        
| 135 | 135 |  		if (!$ping) { | 
                                                        
| 136 | -			return $this->getAPIResponse(['message' => 'GIT update (' . $ID . ') not found'], 404); | 
                                                        |
| 136 | +			return $this->getAPIResponse(['message' => 'GIT update ('.$ID.') not found'], 404); | 
                                                        |
| 137 | 137 | }  | 
                                                        
| 138 | 138 | $output = [  | 
                                                        
| 139 | 139 | 'id' => $ID,  | 
                                                        
@@ -154,7 +154,7 @@ discard block  | 
                                                    ||
| 154 | 154 | $fetch->write();  | 
                                                        
| 155 | 155 | $fetch->start();  | 
                                                        
| 156 | 156 | |
| 157 | - $location = Director::absoluteBaseURL() . $this->Link() . '/update/' . $fetch->ID;  | 
                                                        |
| 157 | + $location = Director::absoluteBaseURL().$this->Link().'/update/'.$fetch->ID;  | 
                                                        |
| 158 | 158 | $output = [  | 
                                                        
| 159 | 159 | 'message' => 'git fetch has been queued',  | 
                                                        
| 160 | 160 | 'id' => $fetch->ID,  |