@@ -112,9 +112,9 @@ discard block |
||
| 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 |
||
| 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); |
@@ -105,7 +105,7 @@ discard block |
||
| 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 |
||
| 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 | /** |
@@ -31,7 +31,7 @@ |
||
| 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']); |
@@ -19,7 +19,7 @@ discard block |
||
| 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 |
||
| 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 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 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 |
||
| 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 | /** |
@@ -205,12 +205,16 @@ |
||
| 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( |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function LogLink() { |
| 103 | - return $this->Link() . '/log'; |
|
| 103 | + return $this->Link().'/log'; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function canView($member = null) { |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function getFullDeployMessages() { |
| 221 | 221 | $strategy = $this->getDeploymentStrategy(); |
| 222 | - if ($strategy->getActionCode()!=='full') return null; |
|
| 222 | + if($strategy->getActionCode() !== 'full') return null; |
|
| 223 | 223 | |
| 224 | 224 | $changes = $strategy->getChangesModificationNeeded(); |
| 225 | 225 | $messages = []; |
| 226 | - foreach ($changes as $change => $details) { |
|
| 227 | - if ($change==='Code version') continue; |
|
| 226 | + foreach($changes as $change => $details) { |
|
| 227 | + if($change === 'Code version') continue; |
|
| 228 | 228 | |
| 229 | 229 | $messages[] = [ |
| 230 | 230 | 'Flag' => sprintf( |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | ]; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if (empty($messages)) { |
|
| 238 | + if(empty($messages)) { |
|
| 239 | 239 | $messages[] = [ |
| 240 | 240 | 'Flag' => '', |
| 241 | 241 | 'Text' => '<i>Environment changes have been made.</i>' |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | // if there is a compare URL, and a description or a change (something actually changed) |
| 286 | 286 | // then show the URL. Otherwise don't show anything, as there is no comparison to be made. |
| 287 | - if ($changed || $description) { |
|
| 287 | + if($changed || $description) { |
|
| 288 | 288 | $compareUrl = isset($change['compareUrl']) ? $change['compareUrl'] : ''; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | public function getSigFile() { |
| 350 | 350 | $dir = DNData::inst()->getSignalDir(); |
| 351 | - if (!is_dir($dir)) { |
|
| 351 | + if(!is_dir($dir)) { |
|
| 352 | 352 | `mkdir $dir`; |
| 353 | 353 | } |
| 354 | 354 | return sprintf( |
@@ -89,7 +89,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -73,7 +73,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -1,7 +1,5 @@ |
||
| 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'; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function getModel($name) { |
| 21 | 21 | $deployment = $this->getDeployment(); |
| 22 | - if (!$deployment) { |
|
| 22 | + if(!$deployment) { |
|
| 23 | 23 | return []; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function getDeployment() { |
| 32 | 32 | $id = $this->request->param('Id'); |
| 33 | 33 | $deployment = DNDeployment::get()->byId($id); |
| 34 | - if (!$deployment || !$deployment->exists()) { |
|
| 34 | + if(!$deployment || !$deployment->exists()) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | return $deployment; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function apply(SS_HTTPRequest $request) { |
| 41 | 41 | $this->checkSecurityToken(); |
| 42 | 42 | $response = $this->checkRequest(); |
| 43 | - if ($response instanceof SS_HTTPResponse) { |
|
| 43 | + if($response instanceof SS_HTTPResponse) { |
|
| 44 | 44 | return $response; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function canApply(SS_HTTPRequest $request) { |
| 55 | 55 | $this->checkSecurityToken(); |
| 56 | 56 | $response = $this->checkRequest(); |
| 57 | - if ($response instanceof SS_HTTPResponse) { |
|
| 57 | + if($response instanceof SS_HTTPResponse) { |
|
| 58 | 58 | return $response; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $deployment = $this->getDeployment(); |
| 78 | - if (!$deployment) { |
|
| 78 | + if(!$deployment) { |
|
| 79 | 79 | return new SS_HTTPResponse('Deployment not found', 404); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | protected function getMachine() { |
| 86 | 86 | $deployment = $this->getDeployment(); |
| 87 | - if (!$deployment) { |
|
| 87 | + if(!$deployment) { |
|
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | // It gives a chance to perform a dry-run, and reject the transition, for example |
| 97 | 97 | // in case the user is unauthorised. |
| 98 | 98 | 'finite.test_transition', |
| 99 | - function (Finite\Event\TransitionEvent $e) use ($project) { |
|
| 99 | + function(Finite\Event\TransitionEvent $e) use ($project) { |
|
| 100 | 100 | $code = null; |
| 101 | 101 | |
| 102 | - switch ($e->getTransition()->getName()) { |
|
| 102 | + switch($e->getTransition()->getName()) { |
|
| 103 | 103 | case 'approve': |
| 104 | 104 | $code = self::ALLOW_DNDEPLOYMENT_APPROVE; |
| 105 | 105 | break; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | break; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if (!$code || !$project->allowed($code)) { |
|
| 111 | + if(!$code || !$project->allowed($code)) { |
|
| 112 | 112 | $e->reject(); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -100,12 +100,12 @@ |
||
| 100 | 100 | $code = null; |
| 101 | 101 | |
| 102 | 102 | switch ($e->getTransition()->getName()) { |
| 103 | - case DNDeployment::TR_SUBMIT: |
|
| 104 | - $code = self::ALLOW_DNDEPLOYMENT_SUBMIT; |
|
| 105 | - break; |
|
| 106 | - case DNDeployment::TR_QUEUE: |
|
| 107 | - $code = self::ALLOW_DNDEPLOYMENT_QUEUE; |
|
| 108 | - break; |
|
| 103 | + case DNDeployment::TR_SUBMIT: |
|
| 104 | + $code = self::ALLOW_DNDEPLOYMENT_SUBMIT; |
|
| 105 | + break; |
|
| 106 | + case DNDeployment::TR_QUEUE: |
|
| 107 | + $code = self::ALLOW_DNDEPLOYMENT_QUEUE; |
|
| 108 | + break; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (!$code || !$project->allowed($code)) { |