| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * Base class for the APINouns | |
| 4 | - */ | |
| 3 | + * Base class for the APINouns | |
| 4 | + */ | |
| 5 | 5 |  class APINoun extends Controller { | 
| 6 | 6 | |
| 7 | 7 | /** | 
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | |
| 73 | 73 |  			try { | 
| 74 | 74 | $args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log); | 
| 75 | -			} catch (Exception $e) { | |
| 75 | +			} catch(Exception $e) { | |
| 76 | 76 | $log->write($e->getMessage()); | 
| 77 | 77 | throw $e; | 
| 78 | 78 | } | 
| @@ -130,10 +130,10 @@ | ||
| 130 | 130 | */ | 
| 131 | 131 |  	public function getChangesModificationNeeded() { | 
| 132 | 132 | $filtered = []; | 
| 133 | -		foreach ($this->changes as $change => $details) { | |
| 134 | -			if (array_key_exists('description', $details)) { | |
| 133 | +		foreach($this->changes as $change => $details) { | |
| 134 | +			if(array_key_exists('description', $details)) { | |
| 135 | 135 | $filtered[$change] = $details; | 
| 136 | - } else if ( | |
| 136 | + } else if( | |
| 137 | 137 |  				(array_key_exists('from', $details) || array_key_exists('to', $details)) | 
| 138 | 138 | && $details['from'] !== $details['to'] | 
| 139 | 139 |  			) { | 
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | // Make sure we write into the old path for existing logs. New logs use the sanitised file path instead. | 
| 78 | 78 | $path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath(); | 
| 79 | 79 | |
| 80 | -		error_log('['.date('Y-m-d H:i:s').'] ' . $message .PHP_EOL, 3, $path); | |
| 80 | +		error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path); | |
| 81 | 81 | @chmod($path, 0666); | 
| 82 | 82 | } | 
| 83 | 83 | |
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | */ | 
| 64 | 64 |  	public function asJSONValidatorErrors($code, $validatorErrors) { | 
| 65 | 65 | $fieldErrors = []; | 
| 66 | -		foreach ($validatorErrors as $error) { | |
| 66 | +		foreach($validatorErrors as $error) { | |
| 67 | 67 | $fieldErrors[$error['fieldName']] = $error['message']; | 
| 68 | 68 | } | 
| 69 | 69 | return $this->asJSONFormFieldErrors($code, $fieldErrors); | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | // To get around that, upon spotting an active redirect, we change the response code to 200, | 
| 106 | 106 | // and move the redirect into the "RedirectTo" field in the JSON response. Frontend can | 
| 107 | 107 | // then interpret this and trigger a redirect. | 
| 108 | -		if ($this->redirectedTo()) { | |
| 108 | +		if($this->redirectedTo()) { | |
| 109 | 109 |  			$data['RedirectTo'] = $this->response->getHeader('Location'); | 
| 110 | 110 | // Pop off the header - we are no longer redirecting via the usual mechanism. | 
| 111 | 111 |  			$this->response->removeHeader('Location'); | 
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * Dispatcher provides functionality to make it easier to work with frontend React components. | |
| 4 | - * See deploynaut/docs/dispatcher.md for more information. | |
| 5 | - * | |
| 6 | - * @todo: currently we can't have more than one component mounted in parallel on any given Dispatcher, | |
| 7 | - * because the SecurityID will diverge as soon as one of these components submit. | |
| 8 | - */ | |
| 3 | + * Dispatcher provides functionality to make it easier to work with frontend React components. | |
| 4 | + * See deploynaut/docs/dispatcher.md for more information. | |
| 5 | + * | |
| 6 | + * @todo: currently we can't have more than one component mounted in parallel on any given Dispatcher, | |
| 7 | + * because the SecurityID will diverge as soon as one of these components submit. | |
| 8 | + */ | |
| 9 | 9 | |
| 10 | 10 |  abstract class Dispatcher extends DNRoot { | 
| 11 | 11 | |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 |  class FrontendLink extends DataExtension { | 
| 4 | 4 | |
| 5 | 5 |  	public function updateItemEditForm($form) { | 
| 6 | -		if ($this->owner->record->hasMethod('Link')) { | |
| 6 | +		if($this->owner->record->hasMethod('Link')) { | |
| 7 | 7 | $link = sprintf( | 
| 8 | 8 | '<a style="margin: 0.5em" target="deploynaut-frontend" href="%s">Preview »</a>', | 
| 9 | 9 | $this->owner->record->Link() | 
| @@ -385,10 +385,10 @@ discard block | ||
| 385 | 385 | } | 
| 386 | 386 | // Must be logged in to check permissions | 
| 387 | 387 | |
| 388 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 389 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true; | |
| 388 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 389 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true; | |
| 390 | 390 |  		} else { | 
| 391 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true; | |
| 391 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true; | |
| 392 | 392 | } | 
| 393 | 393 | |
| 394 | 394 | return $this->Deployers()->byID($member->ID) | 
| @@ -411,10 +411,10 @@ discard block | ||
| 411 | 411 | } | 
| 412 | 412 | // Must be logged in to check permissions | 
| 413 | 413 | |
| 414 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 415 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 414 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 415 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 416 | 416 |  		} else { | 
| 417 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 417 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 418 | 418 | } | 
| 419 | 419 | |
| 420 | 420 | return $this->CanRestoreMembers()->byID($member->ID) | 
| @@ -442,10 +442,10 @@ discard block | ||
| 442 | 442 | return false; | 
| 443 | 443 | } | 
| 444 | 444 | |
| 445 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 446 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 445 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 446 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 447 | 447 |  		} else { | 
| 448 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 448 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 449 | 449 | } | 
| 450 | 450 | |
| 451 | 451 | return $this->CanBackupMembers()->byID($member->ID) | 
| @@ -477,10 +477,10 @@ discard block | ||
| 477 | 477 | } | 
| 478 | 478 | // Must be logged in to check permissions | 
| 479 | 479 | |
| 480 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 481 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 480 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 481 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 482 | 482 |  		} else { | 
| 483 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 483 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 484 | 484 | } | 
| 485 | 485 | |
| 486 | 486 | return $this->ArchiveUploaders()->byID($member->ID) | 
| @@ -503,10 +503,10 @@ discard block | ||
| 503 | 503 | } | 
| 504 | 504 | // Must be logged in to check permissions | 
| 505 | 505 | |
| 506 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 507 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 506 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 507 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 508 | 508 |  		} else { | 
| 509 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 509 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 510 | 510 | } | 
| 511 | 511 | |
| 512 | 512 | return $this->ArchiveDownloaders()->byID($member->ID) | 
| @@ -572,10 +572,10 @@ discard block | ||
| 572 | 572 | } | 
| 573 | 573 | // Must be logged in to check permissions | 
| 574 | 574 | |
| 575 | -		if ($this->Usage==='Production' || $this->Usage==='Unspecified') { | |
| 576 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 575 | +		if($this->Usage === 'Production' || $this->Usage === 'Unspecified') { | |
| 576 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; | |
| 577 | 577 |  		} else { | 
| 578 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 578 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; | |
| 579 | 579 | } | 
| 580 | 580 | |
| 581 | 581 | return $this->ArchiveDeleters()->byID($member->ID) | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 | * @return bool | 
| 263 | 263 | */ | 
| 264 | 264 |  	public function canRestore($member = null) { | 
| 265 | - if ($this->allowedAny( | |
| 265 | + if($this->allowedAny( | |
| 266 | 266 | array( | 
| 267 | 267 | DNRoot::ALLOW_PROD_SNAPSHOT, | 
| 268 | 268 | DNRoot::ALLOW_NON_PROD_SNAPSHOT | 
| @@ -282,7 +282,7 @@ discard block | ||
| 282 | 282 | * @return bool | 
| 283 | 283 | */ | 
| 284 | 284 |  	public function canBackup($member = null) { | 
| 285 | - if ($this->allowedAny( | |
| 285 | + if($this->allowedAny( | |
| 286 | 286 | array( | 
| 287 | 287 | DNRoot::ALLOW_PROD_SNAPSHOT, | 
| 288 | 288 | DNRoot::ALLOW_NON_PROD_SNAPSHOT | 
| @@ -302,7 +302,7 @@ discard block | ||
| 302 | 302 | * @return bool | 
| 303 | 303 | */ | 
| 304 | 304 |  	public function canUploadArchive($member = null) { | 
| 305 | - if ($this->allowedAny( | |
| 305 | + if($this->allowedAny( | |
| 306 | 306 | array( | 
| 307 | 307 | DNRoot::ALLOW_PROD_SNAPSHOT, | 
| 308 | 308 | DNRoot::ALLOW_NON_PROD_SNAPSHOT | 
| @@ -322,7 +322,7 @@ discard block | ||
| 322 | 322 | * @return bool | 
| 323 | 323 | */ | 
| 324 | 324 |  	public function canDownloadArchive($member = null) { | 
| 325 | - if ($this->allowedAny( | |
| 325 | + if($this->allowedAny( | |
| 326 | 326 | array( | 
| 327 | 327 | DNRoot::ALLOW_PROD_SNAPSHOT, | 
| 328 | 328 | DNRoot::ALLOW_NON_PROD_SNAPSHOT | 
| @@ -498,14 +498,14 @@ discard block | ||
| 498 | 498 | * @return false|DNDeployment | 
| 499 | 499 | */ | 
| 500 | 500 |  	public function currentBuilds() { | 
| 501 | -		if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { | |
| 501 | +		if(!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { | |
| 502 | 502 | $currentBuilds = array(); | 
| 503 | 503 |  			foreach($this->Environments() as $env) { | 
| 504 | 504 | $currentBuilds[$env->Name] = $env->CurrentBuild(); | 
| 505 | 505 | } | 
| 506 | - self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; | |
| 506 | + self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; | |
| 507 | 507 | } | 
| 508 | - return self::$relation_cache['currentBuilds.'.$this->ID]; | |
| 508 | + return self::$relation_cache['currentBuilds.' . $this->ID]; | |
| 509 | 509 | } | 
| 510 | 510 | |
| 511 | 511 | /** | 
| @@ -987,14 +987,14 @@ discard block | ||
| 987 | 987 | * @return bool | 
| 988 | 988 | */ | 
| 989 | 989 |  	public function allowedAny($codes, $member = null) { | 
| 990 | -		if (!$member) { | |
| 990 | +		if(!$member) { | |
| 991 | 991 | $member = Member::currentUser(); | 
| 992 | 992 | } | 
| 993 | 993 | |
| 994 | 994 | if(Permission::checkMember($member, 'ADMIN')) return true; | 
| 995 | 995 | |
| 996 | 996 |  		$hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count(); | 
| 997 | - return ($hits>0 ? true : false); | |
| 997 | + return ($hits > 0 ? true : false); | |
| 998 | 998 | } | 
| 999 | 999 | |
| 1000 | 1000 | /** | 
| @@ -201,12 +201,12 @@ discard block | ||
| 201 | 201 | */ | 
| 202 | 202 |  	public function getFullDeployMessages() { | 
| 203 | 203 | $strategy = $this->getDeploymentStrategy(); | 
| 204 | - if ($strategy->getActionCode()!=='full') return null; | |
| 204 | + if($strategy->getActionCode() !== 'full') return null; | |
| 205 | 205 | |
| 206 | 206 | $changes = $strategy->getChangesModificationNeeded(); | 
| 207 | 207 | $messages = []; | 
| 208 | -		foreach ($changes as $change => $details) { | |
| 209 | - if ($change==='Code version') continue; | |
| 208 | +		foreach($changes as $change => $details) { | |
| 209 | + if($change === 'Code version') continue; | |
| 210 | 210 | |
| 211 | 211 | $messages[] = [ | 
| 212 | 212 | 'Flag' => sprintf( | 
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | ]; | 
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | -		if (empty($messages)) { | |
| 220 | +		if(empty($messages)) { | |
| 221 | 221 | $messages[] = [ | 
| 222 | 222 | 'Flag' => '', | 
| 223 | 223 | 'Text' => '<i>Environment changes have been made.</i>' |