Completed
Pull Request — master (#642)
by Stig
03:52 queued 37s
created
code/jobs/CreateEnvJob.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 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
 		// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
24 24
 		try {
25 25
 			$envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 			$envCreate->createEnvironment();
32 32
 
33 33
 		} catch(Exception $e) {
34
-			echo "[-] CreateEnvJob failed" . PHP_EOL;
34
+			echo "[-] CreateEnvJob failed".PHP_EOL;
35 35
 			throw $e;
36 36
 		}
37 37
 		$this->updateStatus('Finished');
38
-		echo "[-] CreateEnvJob finished" . PHP_EOL;
38
+		echo "[-] CreateEnvJob finished".PHP_EOL;
39 39
 	}
40 40
 
41 41
 	/**
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -205,12 +205,16 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public function LogLink() {
104
-		return $this->Link() . '/log';
104
+		return $this->Link().'/log';
105 105
 	}
106 106
 
107 107
 	public function canView($member = null) {
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function getCommitURL() {
179 179
 		$environment = $this->Environment();
180
-		if (!$environment) {
180
+		if(!$environment) {
181 181
 			return null;
182 182
 		}
183 183
 		$project = $environment->Project();
184
-		if (!$project) {
184
+		if(!$project) {
185 185
 			return null;
186 186
 		}
187 187
 		$interface = $project->getRepositoryInterface();
188
-		if (!$interface) {
188
+		if(!$interface) {
189 189
 			return null;
190 190
 		}
191
-		return $interface->CommitURL . '/' . $this->SHA;
191
+		return $interface->CommitURL.'/'.$this->SHA;
192 192
 	}
193 193
 
194 194
 	/**
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function getFullDeployMessages() {
239 239
 		$strategy = $this->getDeploymentStrategy();
240
-		if ($strategy->getActionCode()!=='full') return null;
240
+		if($strategy->getActionCode() !== 'full') return null;
241 241
 
242 242
 		$changes = $strategy->getChangesModificationNeeded();
243 243
 		$messages = [];
244
-		foreach ($changes as $change => $details) {
245
-			if ($change==='Code version') continue;
244
+		foreach($changes as $change => $details) {
245
+			if($change === 'Code version') continue;
246 246
 
247 247
 			$messages[] = [
248 248
 				'Flag' => sprintf(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			];
254 254
 		}
255 255
 
256
-		if (empty($messages)) {
256
+		if(empty($messages)) {
257 257
 			$messages[] = [
258 258
 				'Flag' => '',
259 259
 				'Text' => '<i>Environment changes have been made.</i>'
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 			// if there is a compare URL, and a description or a change (something actually changed)
304 304
 			// then show the URL. Otherwise don't show anything, as there is no comparison to be made.
305
-			if ($changed || $description) {
305
+			if($changed || $description) {
306 306
 				$compareUrl = isset($change['compareUrl']) ? $change['compareUrl'] : '';
307 307
 			}
308 308
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
 	public function getSigFile() {
368 368
 		$dir = DNData::inst()->getSignalDir();
369
-		if (!is_dir($dir)) {
369
+		if(!is_dir($dir)) {
370 370
 			`mkdir $dir`;
371 371
 		}
372 372
 		return sprintf(
Please login to merge, or discard this patch.
code/model/DNData.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function setEnvironmentDir($environmentDir) {
91 91
 		if($environmentDir[0] != "/") {
92
-			$environmentDir = BASE_PATH . '/' . $environmentDir;
92
+			$environmentDir = BASE_PATH.'/'.$environmentDir;
93 93
 		}
94 94
 		$this->environmentDir = realpath($environmentDir) ?: $environmentDir;
95 95
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function setKeyDir($keyDir) {
112 112
 		if($keyDir[0] != "/") {
113
-			$keyDir = BASE_PATH . '/' . $keyDir;
113
+			$keyDir = BASE_PATH.'/'.$keyDir;
114 114
 		}
115 115
 		$this->keyDir = realpath($keyDir) ?: $keyDir;
116 116
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function setSignalDir($signalDir) {
129 129
 		if($signalDir[0] != "/") {
130
-			$signalDir = BASE_PATH . '/' . $signalDir;
130
+			$signalDir = BASE_PATH.'/'.$signalDir;
131 131
 		}
132 132
 		$this->signalDir = realpath($signalDir) ?: $signalDir;
133 133
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function setDataTransferDir($transferDir) {
171 171
 		if($transferDir[0] != "/") {
172
-			$transferDir = BASE_PATH . '/' . $transferDir;
172
+			$transferDir = BASE_PATH.'/'.$transferDir;
173 173
 		}
174 174
 		if(strpos($transferDir, ASSETS_PATH) === false) {
175 175
 			throw new LogicException(sprintf(
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	public function getProjectPaths() {
200 200
 		$paths = array();
201 201
 		if(!file_exists($this->getEnvironmentDir())) {
202
-			$eMessage = 'The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it '
202
+			$eMessage = 'The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it '
203 203
 			. 'first and add some projects to it.';
204 204
 			throw new Exception($eMessage);
205 205
 		}
206 206
 		foreach(scandir($this->getEnvironmentDir()) as $project) {
207 207
 			// Exlcude dot-prefixed directories (.git was getting in the way)
208 208
 			if(preg_match('/^[^\.]/', $project)) {
209
-				$path = $this->getEnvironmentDir() . '/' . $project;
209
+				$path = $this->getEnvironmentDir().'/'.$project;
210 210
 				if(is_dir($path) && $project != '.' && $project != '..') {
211 211
 					$paths[] = $project;
212 212
 				}
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 * Returns an array of paths
222 222
 	 */
223 223
 	public function getEnvironmentPaths($project) {
224
-		$baseDir = $this->getEnvironmentDir() . '/' . $project;
224
+		$baseDir = $this->getEnvironmentDir().'/'.$project;
225 225
 
226 226
 		$paths = array();
227 227
 		if(!file_exists($baseDir)) {
228
-			throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.');
228
+			throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.');
229 229
 		}
230 230
 		// Search the directory for config files.
231 231
 		foreach(scandir($baseDir) as $environmentFile) {
Please login to merge, or discard this patch.
code/control/DNDeploymentDispatcher.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use Finite\StateMachine\StateMachine;
4
-
5 3
 class DNDeploymentDispatcher extends Dispatcher {
6 4
 
7 5
 	const ALLOW_DNDEPLOYMENT_APPROVE = 'ALLOW_DNDEPLOYMENT_APPROVE';
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function getModel($name) {
19 19
 		$deployment = $this->getDeployment();
20
-		if (!$deployment) {
20
+		if(!$deployment) {
21 21
 			return [];
22 22
 		}
23 23
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function getDeployment() {
30 30
 		$id = $this->request->param('Id');
31 31
 		$deployment = DNDeployment::get()->byId($id);
32
-		if (!$deployment || !$deployment->exists()) {
32
+		if(!$deployment || !$deployment->exists()) {
33 33
 			return false;
34 34
 		}
35 35
 		return $deployment;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	public function apply(SS_HTTPRequest $request) {
39 39
 		$this->checkSecurityToken();
40 40
 		$response = $this->checkRequest();
41
-		if ($response instanceof SS_HTTPResponse) {
41
+		if($response instanceof SS_HTTPResponse) {
42 42
 			return $response;
43 43
 		}
44 44
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	public function canApply(SS_HTTPRequest $request) {
53 53
 		$this->checkSecurityToken();
54 54
 		$response = $this->checkRequest();
55
-		if ($response instanceof SS_HTTPResponse) {
55
+		if($response instanceof SS_HTTPResponse) {
56 56
 			return $response;
57 57
 		}
58 58
 
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 
64 64
 	protected function checkRequest() {
65 65
 		$project = $this->getCurrentProject();
66
-		if (!$project) {
66
+		if(!$project) {
67 67
 			return $this->project404Response();
68 68
 		}
69 69
 
70 70
 		$env = $this->getCurrentEnvironment($project);
71
-		if (!$env) {
71
+		if(!$env) {
72 72
 			return $this->environment404Response();
73 73
 		}
74 74
 
75 75
 		$deployment = $this->getDeployment();
76
-		if (!$deployment) {
76
+		if(!$deployment) {
77 77
 			return new SS_HTTPResponse('Deployment not found', 404);
78 78
 		}
79 79
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 	protected function getMachine() {
84 84
 		$deployment = $this->getDeployment();
85
-		if (!$deployment) {
85
+		if(!$deployment) {
86 86
 			return null;
87 87
 		}
88 88
 
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 		// It gives a chance to perform a dry-run, and reject the transition, for example
95 95
 		// in case the user is unauthorised.
96 96
 			'finite.test_transition',
97
-			function (Finite\Event\TransitionEvent $e) use ($project) {
97
+			function(Finite\Event\TransitionEvent $e) use ($project) {
98 98
 				$code = null;
99 99
 
100
-				switch ($e->getTransition()->getName()) {
100
+				switch($e->getTransition()->getName()) {
101 101
 					case DNDeployment::TR_SUBMIT:
102 102
 						$code = self::ALLOW_DNDEPLOYMENT_SUBMIT;
103 103
 						break;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 						break;
107 107
 				}
108 108
 
109
-				if (!$code || !$project->allowed($code)) {
109
+				if(!$code || !$project->allowed($code)) {
110 110
 					$e->reject();
111 111
 				}
112 112
 			}
Please login to merge, or discard this patch.
code/model/StateMachineFactory.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,17 +58,17 @@
 block discarded – undo
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])) return;
62 62
 
63 63
 		$transitions = $this->config()->handlers[$class];
64
-		foreach ($transitions as $transName => $handlers) {
65
-			if (!is_array($handlers)) {
64
+		foreach($transitions as $transName => $handlers) {
65
+			if(!is_array($handlers)) {
66 66
 				throw new Exception(sprintf('Transition %s must be configured as an assoc array.', $transName));
67 67
 			}
68 68
 
69
-			foreach ($handlers as $handlerClass => $handlerMethod) {
69
+			foreach($handlers as $handlerClass => $handlerMethod) {
70 70
 				$handlerObj = Injector::inst()->get($handlerClass);
71
-				if (!is_callable([$handlerObj, $handlerMethod])) {
71
+				if(!is_callable([$handlerObj, $handlerMethod])) {
72 72
 					throw new Exception(sprintf('Handler %s is not callable on %s.', $handlerMethod, $handlerClass));
73 73
 				}
74 74
 				$machine->getDispatcher()->addListener(
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
code/control/DNDeploymentHandlers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	protected function sendEmailToApprover(DNDeployment $deployment) {
13 13
 		$deployer = $deployment->Deployer();
14 14
 		$approver = $deployment->Approver();
15
-		if (!$approver || !$approver->exists()) {
15
+		if(!$approver || !$approver->exists()) {
16 16
 			return false;
17 17
 		}
18 18
 
Please login to merge, or discard this patch.
code/tasks/MigrateDeploymentStatusTask.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,28 +4,28 @@
 block discarded – undo
4 4
 
5 5
 	public function run($request) {
6 6
 		$log = function($message) {
7
-			$message = sprintf('[%s] ', date('Y-m-d H:i:s')) . $message;
8
-			echo $message . PHP_EOL;
7
+			$message = sprintf('[%s] ', date('Y-m-d H:i:s')).$message;
8
+			echo $message.PHP_EOL;
9 9
 		};
10 10
 
11
-		if (!Director::is_cli()) {
11
+		if(!Director::is_cli()) {
12 12
 			$log('This command can only run via CLI');
13 13
 			return;
14 14
 		}
15 15
 
16 16
 		$columns = DB::query('SHOW COLUMNS FROM "DNDeployment"')->column();
17
-		if (!in_array('Status', $columns)) {
17
+		if(!in_array('Status', $columns)) {
18 18
 			$log('Migration has already been run');
19 19
 			return;
20 20
 		}
21 21
 
22
-		foreach (DB::query('SELECT "ID", "Status" FROM "DNDeployment"') as $record) {
22
+		foreach(DB::query('SELECT "ID", "Status" FROM "DNDeployment"') as $record) {
23 23
 			// This record looks to be already migrated
24
-			if (empty($record['Status'])) {
24
+			if(empty($record['Status'])) {
25 25
 				continue;
26 26
 			}
27 27
 
28
-			switch ($record['Status']) {
28
+			switch($record['Status']) {
29 29
 				case 'Queued':
30 30
 					DB::query(sprintf('UPDATE "DNDeployment" SET "State" = \'Queued\' WHERE "ID" = %s', $record['ID']));
31 31
 					break;
Please login to merge, or discard this patch.
code/backends/SimplePackageGenerator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * Generate the package
31 31
 	 */
32 32
 	public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) {
33
-		$tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename));
33
+		$tempPath = TEMP_FOLDER."/".str_replace(".tar.gz", "", basename($outputFilename));
34 34
 		if(!file_exists($tempPath)) {
35 35
 			mkdir($tempPath);
36 36
 		}
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
 		// Execute these in sequence until there's a failure
43 43
 		$processes = array(
44 44
 			// Export the relevant SHA into a temp folder
45
-			new AbortableProcess("git archive $sha | tar -x -C " . $escapedTempPath, $baseDir),
45
+			new AbortableProcess("git archive $sha | tar -x -C ".$escapedTempPath, $baseDir),
46 46
 			// Run build script
47 47
 			new AbortableProcess($this->buildScript, $tempPath, null, null, 3600),
48 48
 			// Compress the result
49
-			new AbortableProcess("tar -czf " . $escapedOutputFile . " " . $escapedTempDir, dirname($tempPath)),
49
+			new AbortableProcess("tar -czf ".$escapedOutputFile." ".$escapedTempDir, dirname($tempPath)),
50 50
 		);
51 51
 
52 52
 		// Call at the end, regardless of success or failure
53 53
 		$cleanup = array(
54 54
 			// Delete the temporary staging folder
55
-			new AbortableProcess("rm -rf " . $escapedTempPath),
55
+			new AbortableProcess("rm -rf ".$escapedTempPath),
56 56
 		);
57 57
 
58 58
 		try {
Please login to merge, or discard this patch.
code/AbortableProcess.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 			sleep(1);
21 21
 		}
22 22
 
23
-		if ($this->hasBeenSignaled()) {
23
+		if($this->hasBeenSignaled()) {
24 24
 			throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->getTermSignal));
25 25
 		}
26 26
 
Please login to merge, or discard this patch.