Completed
Pull Request — master (#681)
by Sean
06:15
created
code/model/DNEnvironment.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
code/model/DNBranch.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 * @return string
51 51
 	 */
52 52
 	public function Name() {
53
-		return (string)htmlentities($this->branch->getName());
53
+		return (string) htmlentities($this->branch->getName());
54 54
 	}
55 55
 
56 56
 	public function Link() {
57 57
 		// Use a get-var for branch so that it can handle unsafe chars better
58
-		return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name()));
58
+		return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name()));
59 59
 	}
60 60
 
61 61
 	/**
62 62
 	 * @return string
63 63
 	 */
64 64
 	public function SHA() {
65
-		return (string)htmlentities($this->branch->getCommit()->getHash());
65
+		return (string) htmlentities($this->branch->getCommit()->getHash());
66 66
 	}
67 67
 
68 68
 	/**
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function LastUpdated() {
80 80
 
81
-		if($this->_lastUpdatedCache) {
81
+		if ($this->_lastUpdatedCache) {
82 82
 			return $this->_lastUpdatedCache;
83 83
 		}
84 84
 		try {
85 85
 			$created = $this->branch->getCommit()->getCommitterDate();
86
-		} catch(Exception $e) {
86
+		} catch (Exception $e) {
87 87
 			//occasionally parsing will fail this is a fallback to make it still work
88 88
 			return new SS_Datetime();
89 89
 		}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return string
104 104
 	 */
105 105
 	public function IsOpenByDefault() {
106
-		if($this->Name() == 'master') {
106
+		if ($this->Name() == 'master') {
107 107
 			return " open";
108 108
 		} else {
109 109
 			return "";
Please login to merge, or discard this patch.
code/control/Dispatcher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@
 block discarded – undo
144 144
 		$output['status_code'] = $statusCode;
145 145
 		$response = $this->getResponse();
146 146
 		$response->addHeader('Content-Type', 'application/json');
147
-		$response->setBody(json_encode($output, JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK));
147
+		$response->setBody(json_encode($output, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK));
148 148
 		$response->setStatusCode($statusCode);
149 149
 		return $response;
150 150
 	}
Please login to merge, or discard this patch.
code/control/DeployDispatcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -263,12 +263,12 @@
 block discarded – undo
263 263
 
264 264
 		// failover for older deployments
265 265
 		$started = $deployment->Created;
266
-		if($deployment->DeployStarted) {
266
+		if ($deployment->DeployStarted) {
267 267
 			$started = $deployment->DeployStarted;
268 268
 		}
269 269
 
270 270
 		$requested = $deployment->Created;
271
-		if($deployment->DeployRequested) {
271
+		if ($deployment->DeployRequested) {
272 272
 			$requested = $deployment->DeployRequested;
273 273
 		}
274 274
 
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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',
Please login to merge, or discard this patch.
code/model/DNProject.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$cache = self::get_git_cache();
161 161
 		// we only need to clear the tag cache since everything else is cached by SHA, that is for commit and
162 162
 		// commit message.
163
-		$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_' . $this->ID]);
163
+		$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_'.$this->ID]);
164 164
 	}
165 165
 
166 166
 	/**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			return true;
332 332
 		}
333 333
 
334
-		return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) {
334
+		return (bool) $this->Environments()->filterByCallback(function($env) use ($member) {
335 335
 			return $env->canRestore($member);
336 336
 		})->Count();
337 337
 	}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			return true;
353 353
 		}
354 354
 
355
-		return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) {
355
+		return (bool) $this->Environments()->filterByCallback(function($env) use ($member) {
356 356
 			return $env->canBackup($member);
357 357
 		})->Count();
358 358
 	}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			return true;
374 374
 		}
375 375
 
376
-		return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) {
376
+		return (bool) $this->Environments()->filterByCallback(function($env) use ($member) {
377 377
 			return $env->canUploadArchive($member);
378 378
 		})->Count();
379 379
 	}
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 			return true;
395 395
 		}
396 396
 
397
-		return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) {
397
+		return (bool) $this->Environments()->filterByCallback(function($env) use ($member) {
398 398
 			return $env->canDownloadArchive($member);
399 399
 		})->Count();
400 400
 	}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			// Key-pair is available, use it.
454 454
 			$processEnv = [
455 455
 				'IDENT_KEY' => $this->getPrivateKeyPath(),
456
-				'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh"
456
+				'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh"
457 457
 			];
458 458
 		} else {
459 459
 			$processEnv = [];
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
 		$currentMember = self::$_current_member_cache;
543 543
 		return $this->Environments()
544
-			->filterByCallBack(function ($item) use ($currentMember) {
544
+			->filterByCallBack(function($item) use ($currentMember) {
545 545
 				return $item->canView($currentMember);
546 546
 			});
547 547
 	}
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 	 * @return false|DNDeployment
561 561
 	 */
562 562
 	public function currentBuilds() {
563
-		if (!isset(self::$relation_cache['currentBuilds.' . $this->ID])) {
563
+		if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) {
564 564
 			$currentBuilds = [];
565 565
 			foreach ($this->Environments() as $env) {
566 566
 				$currentBuilds[$env->Name] = $env->CurrentBuild();
567 567
 			}
568
-			self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds;
568
+			self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds;
569 569
 		}
570
-		return self::$relation_cache['currentBuilds.' . $this->ID];
570
+		return self::$relation_cache['currentBuilds.'.$this->ID];
571 571
 	}
572 572
 
573 573
 	/**
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 	 */
809 809
 	public function getPublicKeyPath() {
810 810
 		if ($privateKey = $this->getPrivateKeyPath()) {
811
-			return $privateKey . '.pub';
811
+			return $privateKey.'.pub';
812 812
 		}
813 813
 		return null;
814 814
 	}
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		if (!empty($keyDir)) {
824 824
 			$filter = FileNameFilter::create();
825 825
 			$name = $filter->filter($this->Name);
826
-			return $keyDir . '/' . $name;
826
+			return $keyDir.'/'.$name;
827 827
 		}
828 828
 		return null;
829 829
 	}
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		$filter = FileNameFilter::create();
843 843
 		$name = $filter->filter($this->Name);
844 844
 
845
-		return $this->DNData()->getKeyDir() . '/' . $name;
845
+		return $this->DNData()->getKeyDir().'/'.$name;
846 846
 	}
847 847
 
848 848
 	/**
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 		/* Look for each whitelisted hostname */
869 869
 		foreach ($interfaces as $host => $interface) {
870 870
 			/* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */
871
-			if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
871
+			if (preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
872 872
 
873 873
 				$path = $match[2];
874 874
 
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
 				$components = explode('.', $host);
880 880
 
881 881
 				foreach ($regex as $pattern => $replacement) {
882
-					$path = preg_replace('/' . $pattern . '/', $replacement, $path);
882
+					$path = preg_replace('/'.$pattern.'/', $replacement, $path);
883 883
 				}
884 884
 
885
-				$uxurl = Controller::join_links($scheme . '://', $host, $path);
885
+				$uxurl = Controller::join_links($scheme.'://', $host, $path);
886 886
 
887 887
 				if (array_key_exists('commit', $interface) && $interface['commit'] == false) {
888 888
 					$commiturl = false;
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 		// {@see DataObject::extendedCan()}
1010 1010
 		$isDone = $this->extend('isProjectReady');
1011 1011
 		if ($isDone && is_array($isDone)) {
1012
-			$isDone = array_filter($isDone, function ($val) {
1012
+			$isDone = array_filter($isDone, function($val) {
1013 1013
 				return !is_null($val);
1014 1014
 			});
1015 1015
 
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
 			return false;
1095 1095
 		}
1096 1096
 
1097
-		$cachekey = $this->ID . '_commit_' . $sha;
1097
+		$cachekey = $this->ID.'_commit_'.$sha;
1098 1098
 		$cache = self::get_git_cache();
1099 1099
 		if (!($result = $cache->load($cachekey))) {
1100 1100
 			$result = $repo->getCommit($sha);
1101
-			$cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_' . $this->ID]);
1101
+			$cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_'.$this->ID]);
1102 1102
 		}
1103 1103
 		return $result;
1104 1104
 	}
@@ -1108,11 +1108,11 @@  discard block
 block discarded – undo
1108 1108
 	 * @return string
1109 1109
 	 */
1110 1110
 	public function getCommitMessage(\Gitonomy\Git\Commit $commit) {
1111
-		$cachekey = $this->ID . '_message_' . $commit->getRevision();
1111
+		$cachekey = $this->ID.'_message_'.$commit->getRevision();
1112 1112
 		$cache = self::get_git_cache();
1113 1113
 		if (!($result = $cache->load($cachekey))) {
1114 1114
 			$result = $commit->getMessage();
1115
-			$cache->save($result, $cachekey, ['gitonomy', 'message', 'project_' . $this->ID]);
1115
+			$cache->save($result, $cachekey, ['gitonomy', 'message', 'project_'.$this->ID]);
1116 1116
 		}
1117 1117
 		return $result;
1118 1118
 	}
@@ -1122,14 +1122,14 @@  discard block
 block discarded – undo
1122 1122
 	 * @return mixed
1123 1123
 	 */
1124 1124
 	public function getCommitTags(\Gitonomy\Git\Commit $commit) {
1125
-		$cachekey = $this->ID . '_tags_' . $commit->getRevision();
1125
+		$cachekey = $this->ID.'_tags_'.$commit->getRevision();
1126 1126
 		$cache = self::get_git_cache();
1127 1127
 		$result = $cache->load($cachekey);
1128 1128
 		// we check against false, because in many cases the tag list is an empty array
1129 1129
 		if ($result === false) {
1130 1130
 			$repo = $this->getRepository();
1131 1131
 			$result = $tags = $repo->getReferences()->resolveTags($commit->getRevision());
1132
-			$cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_' . $this->ID]);
1132
+			$cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_'.$this->ID]);
1133 1133
 		}
1134 1134
 		return $result;
1135 1135
 	}
Please login to merge, or discard this patch.
code/backends/CapistranoDeploymentBackend.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$currentBuild = $environment->CurrentBuild();
27 27
 		$currentSha = $currentBuild ? $currentBuild->SHA : '-';
28
-		if($currentSha !== $options['sha']) {
28
+		if ($currentSha !== $options['sha']) {
29 29
 			$strategy->setChange('Code version', $currentSha, $options['sha']);
30 30
 		}
31 31
 		$strategy->setActionTitle('Confirm deployment');
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 		// Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour
68 68
 		// if build_filename isn't specified
69
-		if($this->packageGenerator) {
69
+		if ($this->packageGenerator) {
70 70
 			$log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator)));
71 71
 
72 72
 			try {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				throw $e;
77 77
 			}
78 78
 
79
-			if(empty($args['build_filename'])) {
79
+			if (empty($args['build_filename'])) {
80 80
 				throw new RuntimeException('Failed to generate package.');
81 81
 			}
82 82
 		}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 				$log->write($buffer);
95 95
 			});
96 96
 
97
-			if(!$command->isSuccessful()) {
97
+			if (!$command->isSuccessful()) {
98 98
 				$self->extend('cleanupFailure', $environment, $sha, $log, $project);
99 99
 				$log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.');
100 100
 			}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$this->enableMaintenance($environment, $log, $project);
106 106
 
107 107
 		$rolledBack = null;
108
-		if(!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
108
+		if (!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
109 109
 			$cleanupFn();
110 110
 			$this->extend('deployFailure', $environment, $sha, $log, $project);
111 111
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		$command->run(function($type, $buffer) use($log) {
172 172
 			$log->write($buffer);
173 173
 		});
174
-		if(!$command->isSuccessful()) {
174
+		if (!$command->isSuccessful()) {
175 175
 			$this->extend('maintenanceEnableFailure', $environment, $log);
176 176
 			throw new RuntimeException($command->getErrorOutput());
177 177
 		}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		$command->run(function($type, $buffer) use($log) {
188 188
 			$log->write($buffer);
189 189
 		});
190
-		if(!$command->isSuccessful()) {
190
+		if (!$command->isSuccessful()) {
191 191
 			$this->extend('maintenanceDisableFailure', $environment, $log);
192 192
 			throw new RuntimeException($command->getErrorOutput());
193 193
 		}
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 * @inheritdoc
210 210
 	 */
211 211
 	public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
212
-		if($dataTransfer->Direction == 'get') {
212
+		if ($dataTransfer->Direction == 'get') {
213 213
 			$this->dataTransferBackup($dataTransfer, $log);
214 214
 		} else {
215 215
 			$environment = $dataTransfer->Environment();
216 216
 			$project = $environment->Project();
217
-			$workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID;
217
+			$workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID;
218 218
 			$archive = $dataTransfer->DataArchive();
219 219
 
220 220
 			// extract the sspak contents, we'll need these so capistrano can restore that content
221 221
 			try {
222 222
 				$archive->extractArchive($workingDir);
223
-			} catch(Exception $e) {
223
+			} catch (Exception $e) {
224 224
 				$log->write($e->getMessage());
225 225
 				throw new RuntimeException($e->getMessage());
226 226
 			}
227 227
 
228 228
 			// validate the contents match the requested transfer mode
229 229
 			$result = $archive->validateArchiveContents($dataTransfer->Mode);
230
-			if(!$result->valid()) {
230
+			if (!$result->valid()) {
231 231
 				// do some cleaning, get rid of the extracted archive lying around
232 232
 				$process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir)));
233 233
 				$process->setTimeout(120);
@@ -257,41 +257,41 @@  discard block
 block discarded – undo
257 257
 		$name = $environment->getFullName();
258 258
 		$env = $environment->Project()->getProcessEnv();
259 259
 
260
-		if(!$args) {
260
+		if (!$args) {
261 261
 			$args = array();
262 262
 		}
263
-		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/');
263
+		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/');
264 264
 		$args['environment_id'] = $environment->ID;
265 265
 
266 266
 		// Inject env string directly into the command.
267 267
 		// Capistrano doesn't like the $process->setEnv($env) we'd normally do below.
268 268
 		$envString = '';
269
-		if(!empty($env)) {
269
+		if (!empty($env)) {
270 270
 			$envString .= 'env ';
271
-			foreach($env as $key => $value) {
271
+			foreach ($env as $key => $value) {
272 272
 				$envString .= "$key=\"$value\" ";
273 273
 			}
274 274
 		}
275 275
 
276 276
 		$data = DNData::inst();
277 277
 		// Generate a capfile from a template
278
-		$capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template');
278
+		$capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template');
279 279
 		$cap = str_replace(
280 280
 			array('<config root>', '<ssh key>', '<base path>'),
281 281
 			array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH),
282 282
 			$capTemplate
283 283
 		);
284 284
 
285
-		if(defined('DEPLOYNAUT_CAPFILE')) {
285
+		if (defined('DEPLOYNAUT_CAPFILE')) {
286 286
 			$capFile = DEPLOYNAUT_CAPFILE;
287 287
 		} else {
288
-			$capFile = ASSETS_PATH . '/Capfile';
288
+			$capFile = ASSETS_PATH.'/Capfile';
289 289
 		}
290 290
 		file_put_contents($capFile, $cap);
291 291
 
292
-		$command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles";
293
-		foreach($args as $argName => $argVal) {
294
-			$command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal);
292
+		$command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles";
293
+		foreach ($args as $argName => $argVal) {
294
+			$command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal);
295 295
 		}
296 296
 
297 297
 		$log->write(sprintf('Running command: %s', $command));
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 		$filepathBase = $dataArchive->generateFilepath($dataTransfer);
326 326
 		mkdir($filepathBase, 0700, true);
327 327
 
328
-		$databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql.gz';
328
+		$databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql.gz';
329 329
 
330 330
 		// Backup database
331
-		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
331
+		if (in_array($dataTransfer->Mode, array('all', 'db'))) {
332 332
 			$log->write(sprintf('Backup of database from "%s" started', $name));
333 333
 			$command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log);
334 334
 			$command->run(function($type, $buffer) use($log) {
335 335
 				$log->write($buffer);
336 336
 			});
337
-			if(!$command->isSuccessful()) {
337
+			if (!$command->isSuccessful()) {
338 338
 				$this->extend('dataTransferFailure', $environment, $log);
339 339
 				throw new RuntimeException($command->getErrorOutput());
340 340
 			}
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 
344 344
 		// Backup assets
345
-		if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
345
+		if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
346 346
 			$log->write(sprintf('Backup of assets from "%s" started', $name));
347 347
 			$command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log);
348 348
 			$command->run(function($type, $buffer) use($log) {
349 349
 				$log->write($buffer);
350 350
 			});
351
-			if(!$command->isSuccessful()) {
351
+			if (!$command->isSuccessful()) {
352 352
 				$this->extend('dataTransferFailure', $environment, $log);
353 353
 				throw new RuntimeException($command->getErrorOutput());
354 354
 			}
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 		$log->write('Creating sspak...');
364 364
 
365 365
 		$sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer));
366
-		$sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename;
366
+		$sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename;
367 367
 
368 368
 		try {
369 369
 			$dataArchive->attachFile($sspakFilepath, $dataTransfer);
370 370
 			$dataArchive->setArchiveFromFiles($filepathBase);
371
-		} catch(Exception $e) {
371
+		} catch (Exception $e) {
372 372
 			$log->write($e->getMessage());
373 373
 			throw new RuntimeException($e->getMessage());
374 374
 		}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		$process = new AbortableProcess(sprintf('rm -rf %s/assets && rm -f %s', escapeshellarg($filepathBase), escapeshellarg($databasePath)));
380 380
 		$process->setTimeout(120);
381 381
 		$process->run();
382
-		if(!$process->isSuccessful()) {
382
+		if (!$process->isSuccessful()) {
383 383
 			$log->write('Could not delete temporary files');
384 384
 			throw new RuntimeException($process->getErrorOutput());
385 385
 		}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 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
 			$log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput()));
403 403
 			throw new RuntimeException($command->getErrorOutput());
404 404
 		}
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 		};
429 429
 
430 430
 		// Restore database into target environment
431
-		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
431
+		if (in_array($dataTransfer->Mode, array('all', 'db'))) {
432 432
 			$log->write(sprintf('Restore of database to "%s" started', $name));
433
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql');
433
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql');
434 434
 			$command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log);
435 435
 			$command->run(function($type, $buffer) use($log) {
436 436
 				$log->write($buffer);
437 437
 			});
438
-			if(!$command->isSuccessful()) {
438
+			if (!$command->isSuccessful()) {
439 439
 				$cleanupFn();
440 440
 				$log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput()));
441 441
 				$this->extend('dataTransferFailure', $environment, $log);
@@ -445,14 +445,14 @@  discard block
 block discarded – undo
445 445
 		}
446 446
 
447 447
 		// Restore assets into target environment
448
-		if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
448
+		if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
449 449
 			$log->write(sprintf('Restore of assets to "%s" started', $name));
450
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets');
450
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets');
451 451
 			$command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log);
452 452
 			$command->run(function($type, $buffer) use($log) {
453 453
 				$log->write($buffer);
454 454
 			});
455
-			if(!$command->isSuccessful()) {
455
+			if (!$command->isSuccessful()) {
456 456
 				$cleanupFn();
457 457
 				$log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput()));
458 458
 				$this->extend('dataTransferFailure', $environment, $log);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		$timeout = 600;
478 478
 		$tick = 60;
479 479
 
480
-		if(!$url) {
480
+		if (!$url) {
481 481
 			$log->write('Skipping site accessible check: no URL found.');
482 482
 			return true;
483 483
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		// query the site every second. Note that if the URL doesn't respond,
509 509
 		// curl_exec will take 5 seconds to timeout (see CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT above)
510 510
 		do {
511
-			if(time() > $start + $timeout) {
511
+			if (time() > $start + $timeout) {
512 512
 				$log->write(sprintf(' * Failed: check for %s timed out after %smin', $url, $timeout / 60));
513 513
 				return false;
514 514
 			}
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
 
518 518
 			// check the HTTP response code for HTTP protocols
519 519
 			$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
520
-			if($status && !in_array($status, [500, 501, 502, 503, 504])) {
520
+			if ($status && !in_array($status, [500, 501, 502, 503, 504])) {
521 521
 				$success = true;
522 522
 			}
523 523
 
524 524
 			// check for any curl errors, mostly for checking the response state of non-HTTP protocols,
525 525
 			// but applies to checks of any protocol
526
-			if($response && !curl_errno($ch)) {
526
+			if ($response && !curl_errno($ch)) {
527 527
 				$success = true;
528 528
 			}
529 529
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			}
552 552
 
553 553
 			sleep(1);
554
-		} while(!$success);
554
+		} while (!$success);
555 555
 
556 556
 		curl_close($ch);
557 557
 		$log->write(' * Success: site is accessible!');
Please login to merge, or discard this patch.
code/jobs/CreateEnvJob.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@
 block discarded – undo
19 19
 	 *
20 20
 	 */
21 21
 	public function perform() {
22
-		echo "[-] CreateEnvJob starting" . PHP_EOL;
22
+		echo "[-] CreateEnvJob starting".PHP_EOL;
23 23
 
24 24
 		$log = new DeploynautLogFile($this->args['logfile']);
25 25
 		$envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
26 26
 
27 27
 		// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
28 28
 		try {
29
-			if(!($envCreate && $envCreate->exists())) {
29
+			if (!($envCreate && $envCreate->exists())) {
30 30
 				throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID']));
31 31
 			}
32 32
 
33 33
 			// This will throw and exception if it fails.
34 34
 			$envCreate->createEnvironment();
35 35
 
36
-		} catch(Exception $e) {
36
+		} catch (Exception $e) {
37 37
 			$log->write($e->getMessage());
38
-			echo "[-] CreateEnvJob failed" . PHP_EOL;
38
+			echo "[-] CreateEnvJob failed".PHP_EOL;
39 39
 			throw $e;
40 40
 		}
41 41
 		$this->updateStatus('Finished');
42
-		echo "[-] CreateEnvJob finished" . PHP_EOL;
42
+		echo "[-] CreateEnvJob finished".PHP_EOL;
43 43
 	}
44 44
 
45 45
 	/**
Please login to merge, or discard this patch.
code/control/EnvironmentOverview.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,12 +70,12 @@
 block discarded – undo
70 70
 	public function getModel($name = '') {
71 71
 		$base = Director::absoluteBaseURL();
72 72
 		return [
73
-			'basename' => Director::baseURL() . $this->getCurrentEnvironment()->Link('overview'),
73
+			'basename' => Director::baseURL().$this->getCurrentEnvironment()->Link('overview'),
74 74
 			'dispatchers' => [
75
-				'git' => $base . $this->getCurrentProject()->Link('git'),
76
-				'plan' => $base . $this->getCurrentEnvironment()->Link('plan'),
77
-				'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys'),
78
-				'approvals' => $base . $this->getCurrentEnvironment()->Link('approvals')
75
+				'git' => $base.$this->getCurrentProject()->Link('git'),
76
+				'plan' => $base.$this->getCurrentEnvironment()->Link('plan'),
77
+				'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys'),
78
+				'approvals' => $base.$this->getCurrentEnvironment()->Link('approvals')
79 79
 			],
80 80
 			'api_auth' => [
81 81
 				'name' => $this->getSecurityToken()->getName(),
Please login to merge, or discard this patch.