Completed
Pull Request — master (#579)
by Mateusz
07:37
created
code/tasks/SyncProjectsAndEnvironments.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
 		if($dryRun) {
21 21
 			echo "Running in dry run mode, no changes commited, ";
22
-			echo "the output shows a prediction on what will happen." . PHP_EOL;
23
-			echo "To skip dryrun, run the task like this:" . PHP_EOL;
24
-			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0" . PHP_EOL . PHP_EOL;
22
+			echo "the output shows a prediction on what will happen.".PHP_EOL;
23
+			echo "To skip dryrun, run the task like this:".PHP_EOL;
24
+			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0".PHP_EOL.PHP_EOL;
25 25
 			sleep(3);
26 26
 		}
27 27
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 
69 69
 		foreach($removeList as $remove) {
70
-			$this->message('Removing "' . basename($remove->Name) . '" from db');
70
+			$this->message('Removing "'.basename($remove->Name).'" from db');
71 71
 			if(!$dryRun) {
72 72
 				$removeList->remove($remove);
73 73
 			}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
 		foreach($removeList as $remove) {
91
-			$this->message($remove->Name . ' ' . $remove->Path);
91
+			$this->message($remove->Name.' '.$remove->Path);
92 92
 			if(!$dryrun) {
93 93
 				$removeList->remove($remove);
94 94
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				continue;
121 121
 			}
122 122
 
123
-			$this->message('Adding "' . basename($path) . '" to db');
123
+			$this->message('Adding "'.basename($path).'" to db');
124 124
 			if(!$dryRun) {
125 125
 				$environment = DNEnvironment::create_from_path($path);
126 126
 				$environment->ProjectID = $project->ID;
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	protected function message($text) {
153 153
 		if(PHP_SAPI !== 'cli') {
154
-			$text = '<p>' . $text . '</p>' . PHP_EOL;
154
+			$text = '<p>'.$text.'</p>'.PHP_EOL;
155 155
 		}
156
-		echo ' - ' . $text . PHP_EOL;
156
+		echo ' - '.$text.PHP_EOL;
157 157
 	}
158 158
 
159 159
 	/**
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function echoHeader($text) {
163 163
 		if(PHP_SAPI !== 'cli') {
164
-			echo '<h2>' . $text . '</h2>' . PHP_EOL;
164
+			echo '<h2>'.$text.'</h2>'.PHP_EOL;
165 165
 		} else {
166
-			echo '# ' . $text . PHP_EOL;
166
+			echo '# '.$text.PHP_EOL;
167 167
 		}
168 168
 	}
169 169
 }
Please login to merge, or discard this patch.
code/api/nouns/APIProject.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,9 +87,9 @@
 block discarded – undo
87 87
 		$fetch->write();
88 88
 		$fetch->start();
89 89
 
90
-		$location = Director::absoluteBaseURL() . $this->Link() . '/fetch/' . $fetch->ID;
90
+		$location = Director::absoluteBaseURL().$this->Link().'/fetch/'.$fetch->ID;
91 91
 		$output = array(
92
-			'message' => 'Fetch queued as job ' . $fetch->ResqueToken,
92
+			'message' => 'Fetch queued as job '.$fetch->ResqueToken,
93 93
 			'href' => $location,
94 94
 		);
95 95
 
Please login to merge, or discard this patch.
code/api/nouns/APIEnvironment.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		$ping->write();
113 113
 		$ping->start();
114 114
 
115
-		$location = Director::absoluteBaseURL() . $this->Link() . '/ping/' . $ping->ID;
115
+		$location = Director::absoluteBaseURL().$this->Link().'/ping/'.$ping->ID;
116 116
 		$output = array(
117
-			'message' => 'Ping queued as job ' . $ping->ResqueToken,
117
+			'message' => 'Ping queued as job '.$ping->ResqueToken,
118 118
 			'href' => $location,
119 119
 		);
120 120
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 		));
165 165
 		$deploy = $strategy->createDeployment();
166 166
 		$deploy->start();
167
-		$location = Director::absoluteBaseURL() . $this->Link() . '/deploy/' . $deploy->ID;
167
+		$location = Director::absoluteBaseURL().$this->Link().'/deploy/'.$deploy->ID;
168 168
 		$output = array(
169
-			'message' => 'Deploy queued as job ' . $deploy->ResqueToken,
169
+			'message' => 'Deploy queued as job '.$deploy->ResqueToken,
170 170
 			'href' => $location,
171 171
 		);
172 172
 		$response = $this->getAPIResponse($output);
Please login to merge, or discard this patch.
code/api/DeploynautAPI.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function project404Response() {
107 107
 		$projectName = Convert::raw2xml($this->getRequest()->latestParam('Project'));
108
-		return new SS_HTTPResponse('Project "' . $projectName . '" not found.', 404);
108
+		return new SS_HTTPResponse('Project "'.$projectName.'" not found.', 404);
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	protected function environment404Response() {
115 115
 		$envName = Convert::raw2xml($this->getRequest()->latestParam('Environment'));
116
-		return new SS_HTTPResponse('Environment "' . $envName . '" not found.', 404);
116
+		return new SS_HTTPResponse('Environment "'.$envName.'" not found.', 404);
117 117
 	}
118 118
 
119 119
 	/**
Please login to merge, or discard this patch.
code/jobs/PingJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
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']);
Please login to merge, or discard this patch.
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/jobs/DataTransferJob.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public function perform() {
23
-		echo "[-] DataTransferJob starting" . PHP_EOL;
23
+		echo "[-] DataTransferJob starting".PHP_EOL;
24 24
 		$log = new DeploynautLogFile($this->args['logfile']);
25 25
 		$dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
26 26
 		$environment = $dataTransfer->Environment();
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		} catch(RuntimeException $exc) {
84 84
 			$log->write($exc->getMessage());
85 85
 
86
-			echo "[-] DataTransferJob failed" . PHP_EOL;
86
+			echo "[-] DataTransferJob failed".PHP_EOL;
87 87
 			throw $exc;
88 88
 		}
89 89
 
90 90
 		$this->updateStatus('Finished');
91
-		echo "[-] DataTransferJob finished" . PHP_EOL;
91
+		echo "[-] DataTransferJob finished".PHP_EOL;
92 92
 	}
93 93
 
94 94
 	/**
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 3 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.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@
 block discarded – undo
53 53
 	);
54 54
 
55 55
 	public function getFiniteState() {
56
-        return $this->State;
57
-    }
56
+		return $this->State;
57
+	}
58 58
 
59
-    public function setFiniteState($state) {
60
-        $this->State = $state;
59
+	public function setFiniteState($state) {
60
+		$this->State = $state;
61 61
 		$this->write();
62
-    }
62
+	}
63 63
 
64 64
 	public function getStatus() {
65 65
 		return $this->State;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 			'transitions' => [
82 82
 				'approve'  => ['from' => ['New'], 'to' => 'Approved'],
83 83
 				'queue'  => ['from' => ['Approved'], 'to' => 'Queued'],
84
-				'invalidate'  => ['from' => ['New','Approved'], 'to' => 'Invalid'],
84
+				'invalidate'  => ['from' => ['New', 'Approved'], 'to' => 'Invalid'],
85 85
 				'deploy'  => ['from' => ['Queued'], 'to' => 'Deploying'],
86
-				'abort'  => ['from' => ['Queued', 'Deploying','Aborting'], 'to' => 'Aborting'],
86
+				'abort'  => ['from' => ['Queued', 'Deploying', 'Aborting'], 'to' => 'Aborting'],
87 87
 				'complete' => ['from' => ['Deploying'], 'to' => 'Completed'],
88 88
 				'fail'  => [
89
-					'from' => ['New','Approved','Queued','Invalid','Deploying','Aborting'],
89
+					'from' => ['New', 'Approved', 'Queued', 'Invalid', 'Deploying', 'Aborting'],
90 90
 					'to' => 'Failed'
91 91
 				],
92 92
 			],
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	public function LogLink() {
127
-		return $this->Link() . '/log';
127
+		return $this->Link().'/log';
128 128
 	}
129 129
 
130 130
 	public function canView($member = null) {
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function getFullDeployMessages() {
245 245
 		$strategy = $this->getDeploymentStrategy();
246
-		if ($strategy->getActionCode()!=='full') return null;
246
+		if($strategy->getActionCode() !== 'full') return null;
247 247
 
248 248
 		$changes = $strategy->getChangesModificationNeeded();
249 249
 		$messages = [];
250
-		foreach ($changes as $change => $details) {
251
-			if ($change==='Code version') continue;
250
+		foreach($changes as $change => $details) {
251
+			if($change === 'Code version') continue;
252 252
 
253 253
 			$messages[] = [
254 254
 				'Flag' => sprintf(
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			];
260 260
 		}
261 261
 
262
-		if (empty($messages)) {
262
+		if(empty($messages)) {
263 263
 			$messages[] = [
264 264
 				'Flag' => '',
265 265
 				'Text' => '<i>Environment changes have been made.</i>'
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
 			// if there is a compare URL, and a description or a change (something actually changed)
310 310
 			// then show the URL. Otherwise don't show anything, as there is no comparison to be made.
311
-			if ($changed || $description) {
311
+			if($changed || $description) {
312 312
 				$compareUrl = isset($change['compareUrl']) ? $change['compareUrl'] : '';
313 313
 			}
314 314
 
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.