Completed
Pull Request — master (#579)
by Mateusz
07:37
created
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/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/DeployForm.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
code/model/DNEnvironment.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 		// Must be logged in to check permissions
309 309
 
310
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
311
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true;
310
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
311
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true;
312 312
 		} else {
313
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true;
313
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true;
314 314
 		}
315 315
 
316 316
 		return $this->Deployers()->byID($member->ID)
@@ -342,10 +342,10 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 		// Must be logged in to check permissions
344 344
 
345
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
346
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
345
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
346
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
347 347
 		} else {
348
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
348
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
349 349
 		}
350 350
 
351 351
 		return $this->CanRestoreMembers()->byID($member->ID)
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 			return false;
374 374
 		}
375 375
 
376
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
377
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
376
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
377
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
378 378
 		} else {
379
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
379
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
380 380
 		}
381 381
 
382 382
 		return $this->CanBackupMembers()->byID($member->ID)
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
 		}
409 409
 		// Must be logged in to check permissions
410 410
 
411
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
412
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
411
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
412
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
413 413
 		} else {
414
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
414
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
415 415
 		}
416 416
 
417 417
 		return $this->ArchiveUploaders()->byID($member->ID)
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
 		}
435 435
 		// Must be logged in to check permissions
436 436
 
437
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
438
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
437
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
438
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
439 439
 		} else {
440
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
440
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
441 441
 		}
442 442
 
443 443
 		return $this->ArchiveDownloaders()->byID($member->ID)
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
 		}
461 461
 		// Must be logged in to check permissions
462 462
 
463
-		if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
464
-			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
463
+		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
464
+			if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true;
465 465
 		} else {
466
-			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
466
+			if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true;
467 467
 		}
468 468
 
469 469
 		return $this->ArchiveDeleters()->byID($member->ID)
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @return string
654 654
 	 */
655 655
 	public function Link() {
656
-		return $this->Project()->Link() . "/environment/" . $this->Name;
656
+		return $this->Project()->Link()."/environment/".$this->Name;
657 657
 	}
658 658
 
659 659
 	/**
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 				->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members)
799 799
 				->setTitle('Who can upload?')
800 800
 				->setDescription(
801
-					'Users who can upload archives linked to this environment into Deploynaut.<br />' .
801
+					'Users who can upload archives linked to this environment into Deploynaut.<br />'.
802 802
 					'Linking them to an environment allows limiting download permissions (see below).'
803 803
 				),
804 804
 
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 		// Add actions
846 846
 		$action = new FormAction('check', 'Check Connection');
847 847
 		$action->setUseButtonTag(true);
848
-		$dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping';
848
+		$dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping';
849 849
 		$action->setAttribute('data-url', $dataURL);
850 850
 		$fields->insertBefore($action, 'Name');
851 851
 
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
 	 */
883 883
 	public function onBeforeWrite() {
884 884
 		parent::onBeforeWrite();
885
-		if($this->Name && $this->Name . '.rb' != $this->Filename) {
886
-			$this->Filename = $this->Name . '.rb';
885
+		if($this->Name && $this->Name.'.rb' != $this->Filename) {
886
+			$this->Filename = $this->Name.'.rb';
887 887
 		}
888 888
 		$this->checkEnvironmentPath();
889 889
 		$this->writeConfigFile();
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 			&& $this->Filename
931 931
 			&& $this->CreateEnvConfig
932 932
 		) {
933
-			$templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template';
933
+			$templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template';
934 934
 			file_put_contents($this->getConfigFilename(), file_get_contents($templateFile));
935 935
 		} else if($this->envFileExists() && $this->DeployConfig) {
936 936
 			file_put_contents($this->getConfigFilename(), $this->DeployConfig);
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 		if(!$this->Filename) {
986 986
 			return '';
987 987
 		}
988
-		return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename;
988
+		return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename;
989 989
 	}
990 990
 
991 991
 	/**
Please login to merge, or discard this patch.
code/jobs/DeployJob.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 	public static function sig_file_for_data_object($dataObject) {
14 14
 		$dir = DNData::inst()->getSignalDir();
15
-		if (!is_dir($dir)) {
15
+		if(!is_dir($dir)) {
16 16
 			`mkdir $dir`;
17 17
 		}
18 18
 		return sprintf(
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function alarmHandler() {
43 43
 		$sigFile = $this->args['sigFile'];
44
-		if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
44
+		if(file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
45 45
 			$signal = (int)file_get_contents($sigFile);
46
-			if (is_int($signal) && in_array((int)$signal, [
46
+			if(is_int($signal) && in_array((int)$signal, [
47 47
 				// The following signals are trapped by both Resque and Rainforest.
48 48
 				SIGTERM,
49 49
 				SIGINT,
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 				SIGCONT
55 55
 			])) {
56 56
 				echo sprintf(
57
-					'[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL,
57
+					'[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL,
58 58
 					$signal,
59 59
 					getmypid()
60 60
 				);
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
 				// Dispatch to own process group.
66 66
 				$pgid = posix_getpgid(getmypid());
67
-				if ($pgid<=0) {
67
+				if($pgid <= 0) {
68 68
 					echo sprintf(
69
-						'[-] Unable to send signal to invalid PGID "%s".' . PHP_EOL,
69
+						'[-] Unable to send signal to invalid PGID "%s".'.PHP_EOL,
70 70
 						$pgid
71 71
 					);
72 72
 				} else {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		posix_setsid();
86 86
 
87 87
 		if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
88
-			if (!empty($this->args['sigFile'])) {
89
-				echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']);
88
+			if(!empty($this->args['sigFile'])) {
89
+				echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']);
90 90
 				declare(ticks = 1);
91 91
 				pcntl_signal(SIGALRM, [$this, 'alarmHandler']);
92 92
 				pcntl_alarm(1);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	public function perform() {
101
-		echo "[-] DeployJob starting" . PHP_EOL;
101
+		echo "[-] DeployJob starting".PHP_EOL;
102 102
 		$log = new DeploynautLogFile($this->args['logfile']);
103 103
 
104 104
 		$deployment = DNDeployment::get()->byID($this->args['deploymentID']);
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 				$this->args
133 133
 			);
134 134
 		} catch(Exception $e) {
135
-			echo "[-] DeployJob failed" . PHP_EOL;
135
+			echo "[-] DeployJob failed".PHP_EOL;
136 136
 			throw $e;
137 137
 		}
138 138
 		$this->updateStatus('Finished');
139
-		echo "[-] DeployJob finished" . PHP_EOL;
139
+		echo "[-] DeployJob finished".PHP_EOL;
140 140
 	}
141 141
 
142 142
 	/**
Please login to merge, or discard this patch.