@@ -23,8 +23,7 @@ discard block |
||
| 23 | 23 | * @package deploynaut |
| 24 | 24 | * @subpackage pipeline |
| 25 | 25 | */ |
| 26 | -class EmergencyRollbackStep extends LongRunningPipelineStep |
|
| 27 | -{ |
|
| 26 | +class EmergencyRollbackStep extends LongRunningPipelineStep { |
|
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | 29 | * @var array |
@@ -44,8 +43,7 @@ discard block |
||
| 44 | 43 | /** |
| 45 | 44 | * @return bool |
| 46 | 45 | */ |
| 47 | - public function start() |
|
| 48 | - { |
|
| 46 | + public function start() { |
|
| 49 | 47 | // Just in case this step is being mistakenly restarted |
| 50 | 48 | if (!empty($this->RolledBack)) { |
| 51 | 49 | $this->log(_t('EmergencyRollbackStep.BEENROLLEDBACK', |
@@ -83,8 +81,7 @@ discard block |
||
| 83 | 81 | * @param Member|null $member |
| 84 | 82 | * @return boolean |
| 85 | 83 | */ |
| 86 | - public function canTriggerRollback($member = null) |
|
| 87 | - { |
|
| 84 | + public function canTriggerRollback($member = null) { |
|
| 88 | 85 | return $this->Pipeline()->Environment()->canDeploy($member) || $this->Pipeline()->canAbort($member); |
| 89 | 86 | } |
| 90 | 87 | |
@@ -93,8 +90,7 @@ discard block |
||
| 93 | 90 | * |
| 94 | 91 | * @return boolean True if successful |
| 95 | 92 | */ |
| 96 | - public function rollback() |
|
| 97 | - { |
|
| 93 | + public function rollback() { |
|
| 98 | 94 | // Check permission |
| 99 | 95 | if (!$this->canTriggerRollback()) { |
| 100 | 96 | return Security::permissionFailure( |
@@ -126,8 +122,7 @@ discard block |
||
| 126 | 122 | /** |
| 127 | 123 | * Dismiss the rollback window |
| 128 | 124 | */ |
| 129 | - public function dismiss() |
|
| 130 | - { |
|
| 125 | + public function dismiss() { |
|
| 131 | 126 | // Check permission |
| 132 | 127 | if (!$this->canTriggerRollback()) { |
| 133 | 128 | return Security::permissionFailure( |
@@ -145,8 +140,7 @@ discard block |
||
| 145 | 140 | /** |
| 146 | 141 | * Initiate the a rollback window |
| 147 | 142 | */ |
| 148 | - public function beginRollbackWindow() |
|
| 149 | - { |
|
| 143 | + public function beginRollbackWindow() { |
|
| 150 | 144 | $this->Status = 'Started'; |
| 151 | 145 | if (!$this->Started) { |
| 152 | 146 | $this->Started = SS_Datetime::now()->Rfc2822(); |
@@ -159,8 +153,7 @@ discard block |
||
| 159 | 153 | return true; |
| 160 | 154 | } |
| 161 | 155 | |
| 162 | - public function getRunningDescription() |
|
| 163 | - { |
|
| 156 | + public function getRunningDescription() { |
|
| 164 | 157 | // Don't show options if this step has already been confirmed |
| 165 | 158 | if ($this->RolledBack) { |
| 166 | 159 | return; |
@@ -170,8 +163,7 @@ discard block |
||
| 170 | 163 | 'You may now roll back to the previous version, if needed.'); |
| 171 | 164 | } |
| 172 | 165 | |
| 173 | - public function allowedActions() |
|
| 174 | - { |
|
| 166 | + public function allowedActions() { |
|
| 175 | 167 | // Don't show options if this step has already been confirmed or can't be confirmed |
| 176 | 168 | if (!$this->canTriggerRollback()) { |
| 177 | 169 | return parent::allowedActions(); |
@@ -9,16 +9,14 @@ discard block |
||
| 9 | 9 | * @package deploynaut |
| 10 | 10 | * @subpackage pipeline |
| 11 | 11 | */ |
| 12 | -class LongRunningPipelineStep extends PipelineStep |
|
| 13 | -{ |
|
| 12 | +class LongRunningPipelineStep extends PipelineStep { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * Determines maximum allowed execution for deployment |
| 17 | 16 | * |
| 18 | 17 | * @return int Number of seconds, or null if not enabled |
| 19 | 18 | */ |
| 20 | - public function getMaxDuration() |
|
| 21 | - { |
|
| 19 | + public function getMaxDuration() { |
|
| 22 | 20 | return $this->getConfigSetting('MaxDuration') ?: null; |
| 23 | 21 | } |
| 24 | 22 | |
@@ -34,8 +32,7 @@ discard block |
||
| 34 | 32 | * |
| 35 | 33 | * @return boolean |
| 36 | 34 | */ |
| 37 | - public function isTimedOut() |
|
| 38 | - { |
|
| 35 | + public function isTimedOut() { |
|
| 39 | 36 | $age = $this->getAge(); |
| 40 | 37 | $timeout = $this->getMaxDuration(); |
| 41 | 38 | return $age && $timeout && ($age > $timeout); |
@@ -46,8 +43,7 @@ discard block |
||
| 46 | 43 | * |
| 47 | 44 | * @return int Age in seconds |
| 48 | 45 | */ |
| 49 | - public function getAge() |
|
| 50 | - { |
|
| 46 | + public function getAge() { |
|
| 51 | 47 | if ($this->Started) { |
| 52 | 48 | $started = intval($this->dbObject('Started')->Format('U')); |
| 53 | 49 | $now = intval(SS_Datetime::now()->Format('U')); |
@@ -58,8 +54,7 @@ discard block |
||
| 58 | 54 | return 0; |
| 59 | 55 | } |
| 60 | 56 | |
| 61 | - public function start() |
|
| 62 | - { |
|
| 57 | + public function start() { |
|
| 63 | 58 | // Ensure started date is set |
| 64 | 59 | if (!$this->Started) { |
| 65 | 60 | $this->Started = SS_Datetime::now()->Rfc2822(); |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | * @package deploynaut |
| 26 | 26 | * @subpackage pipeline |
| 27 | 27 | */ |
| 28 | -class PipelineStep extends DataObject implements PipelineData |
|
| 29 | -{ |
|
| 28 | +class PipelineStep extends DataObject implements PipelineData { |
|
| 30 | 29 | |
| 31 | 30 | /** |
| 32 | 31 | * @var array |
@@ -70,18 +69,15 @@ discard block |
||
| 70 | 69 | * |
| 71 | 70 | * @return string |
| 72 | 71 | */ |
| 73 | - public function getTitle() |
|
| 74 | - { |
|
| 72 | + public function getTitle() { |
|
| 75 | 73 | return $this->Name ?: get_class($this); |
| 76 | 74 | } |
| 77 | 75 | |
| 78 | - public function getTreeTitle() |
|
| 79 | - { |
|
| 76 | + public function getTreeTitle() { |
|
| 80 | 77 | return $this->Title . ' (Status: ' . $this->Status . ')'; |
| 81 | 78 | } |
| 82 | 79 | |
| 83 | - public function getNiceName() |
|
| 84 | - { |
|
| 80 | + public function getNiceName() { |
|
| 85 | 81 | $niceName = $this->getConfigSetting('NiceName') |
| 86 | 82 | ?: ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $this->getTitle())))); |
| 87 | 83 | |
@@ -100,8 +96,7 @@ discard block |
||
| 100 | 96 | * |
| 101 | 97 | * @return array |
| 102 | 98 | */ |
| 103 | - public function getConfigData() |
|
| 104 | - { |
|
| 99 | + public function getConfigData() { |
|
| 105 | 100 | if (!$this->Config) { |
| 106 | 101 | return array(); |
| 107 | 102 | } |
@@ -116,8 +111,7 @@ discard block |
||
| 116 | 111 | return $this->mergedConfig; |
| 117 | 112 | } |
| 118 | 113 | |
| 119 | - public function setConfig($data) |
|
| 120 | - { |
|
| 114 | + public function setConfig($data) { |
|
| 121 | 115 | $this->mergedConfig = null; |
| 122 | 116 | return parent::setField('Config', $data); |
| 123 | 117 | } |
@@ -127,8 +121,7 @@ discard block |
||
| 127 | 121 | * |
| 128 | 122 | * @return string |
| 129 | 123 | */ |
| 130 | - public function getRunningDescription() |
|
| 131 | - { |
|
| 124 | + public function getRunningDescription() { |
|
| 132 | 125 | return ''; |
| 133 | 126 | } |
| 134 | 127 | |
@@ -138,8 +131,7 @@ discard block |
||
| 138 | 131 | * @param string $setting Settings |
| 139 | 132 | * @return mixed Value of setting, or null if not set |
| 140 | 133 | */ |
| 141 | - public function getConfigSetting($setting) |
|
| 142 | - { |
|
| 134 | + public function getConfigSetting($setting) { |
|
| 143 | 135 | $source = $this->getConfigData(); |
| 144 | 136 | foreach (func_get_args() as $setting) { |
| 145 | 137 | if (empty($source[$setting])) { |
@@ -150,8 +142,7 @@ discard block |
||
| 150 | 142 | return $source; |
| 151 | 143 | } |
| 152 | 144 | |
| 153 | - public function finish() |
|
| 154 | - { |
|
| 145 | + public function finish() { |
|
| 155 | 146 | $this->Status = 'Finished'; |
| 156 | 147 | $this->log('Step finished successfully!'); |
| 157 | 148 | $this->write(); |
@@ -162,8 +153,7 @@ discard block |
||
| 162 | 153 | * |
| 163 | 154 | * @param bool $notify Set to false to disable notifications for this failure |
| 164 | 155 | */ |
| 165 | - public function markFailed($notify = true) |
|
| 166 | - { |
|
| 156 | + public function markFailed($notify = true) { |
|
| 167 | 157 | $this->Status = 'Failed'; |
| 168 | 158 | $this->log('Marking pipeline step as failed. See earlier log messages to determine cause.'); |
| 169 | 159 | $this->write(); |
@@ -175,8 +165,7 @@ discard block |
||
| 175 | 165 | * |
| 176 | 166 | * @return boolean |
| 177 | 167 | */ |
| 178 | - public function isQueued() |
|
| 179 | - { |
|
| 168 | + public function isQueued() { |
|
| 180 | 169 | return $this->Status === 'Queued'; |
| 181 | 170 | } |
| 182 | 171 | |
@@ -185,8 +174,7 @@ discard block |
||
| 185 | 174 | * |
| 186 | 175 | * @return boolean |
| 187 | 176 | */ |
| 188 | - public function isRunning() |
|
| 189 | - { |
|
| 177 | + public function isRunning() { |
|
| 190 | 178 | return $this->Status === 'Started'; |
| 191 | 179 | } |
| 192 | 180 | |
@@ -195,8 +183,7 @@ discard block |
||
| 195 | 183 | * |
| 196 | 184 | * @return boolean |
| 197 | 185 | */ |
| 198 | - public function isFinished() |
|
| 199 | - { |
|
| 186 | + public function isFinished() { |
|
| 200 | 187 | return $this->Status === "Finished"; |
| 201 | 188 | } |
| 202 | 189 | |
@@ -206,8 +193,7 @@ discard block |
||
| 206 | 193 | * |
| 207 | 194 | * @return boolean |
| 208 | 195 | */ |
| 209 | - public function isFailed() |
|
| 210 | - { |
|
| 196 | + public function isFailed() { |
|
| 211 | 197 | return $this->Status === "Failed"; |
| 212 | 198 | } |
| 213 | 199 | |
@@ -216,8 +202,7 @@ discard block |
||
| 216 | 202 | * |
| 217 | 203 | * @return boolean |
| 218 | 204 | */ |
| 219 | - public function isAborted() |
|
| 220 | - { |
|
| 205 | + public function isAborted() { |
|
| 221 | 206 | return $this->Status === "Aborted"; |
| 222 | 207 | } |
| 223 | 208 | |
@@ -226,8 +211,7 @@ discard block |
||
| 226 | 211 | * |
| 227 | 212 | * @param string $message |
| 228 | 213 | */ |
| 229 | - public function log($message = "") |
|
| 230 | - { |
|
| 214 | + public function log($message = "") { |
|
| 231 | 215 | $this->Pipeline()->log($message); |
| 232 | 216 | } |
| 233 | 217 | |
@@ -240,8 +224,7 @@ discard block |
||
| 240 | 224 | * |
| 241 | 225 | * @return DNEnvironment The dependent {@link DNEnvironment}. |
| 242 | 226 | */ |
| 243 | - protected function getDependentEnvironment() |
|
| 244 | - { |
|
| 227 | + protected function getDependentEnvironment() { |
|
| 245 | 228 | if ($this->getConfigSetting('PerformTestOn') === 'DependentEnvironment') { |
| 246 | 229 | try { |
| 247 | 230 | $environment = $this->Pipeline()->getDependentEnvironment(); |
@@ -263,8 +246,7 @@ discard block |
||
| 263 | 246 | * |
| 264 | 247 | * @return boolean|null True if successfully started, false if error |
| 265 | 248 | */ |
| 266 | - public function start() |
|
| 267 | - { |
|
| 249 | + public function start() { |
|
| 268 | 250 | $this->Status = 'Started'; |
| 269 | 251 | $this->write(); |
| 270 | 252 | } |
@@ -278,8 +260,7 @@ discard block |
||
| 278 | 260 | * |
| 279 | 261 | * @return boolean True if successfully aborted, false if error |
| 280 | 262 | */ |
| 281 | - public function abort() |
|
| 282 | - { |
|
| 263 | + public function abort() { |
|
| 283 | 264 | if ($this->isQueued() || $this->isRunning()) { |
| 284 | 265 | $this->Status = 'Aborted'; |
| 285 | 266 | $this->log('Step aborted'); |
@@ -303,13 +284,11 @@ discard block |
||
| 303 | 284 | * ) |
| 304 | 285 | * ) |
| 305 | 286 | */ |
| 306 | - public function allowedActions() |
|
| 307 | - { |
|
| 287 | + public function allowedActions() { |
|
| 308 | 288 | return array(); |
| 309 | 289 | } |
| 310 | 290 | |
| 311 | - public function getDryRun() |
|
| 312 | - { |
|
| 291 | + public function getDryRun() { |
|
| 313 | 292 | return $this->Pipeline()->DryRun; |
| 314 | 293 | } |
| 315 | 294 | } |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | * @method DNDataTransfer RollbackDatabase() |
| 23 | 23 | * @property int RollbackDatabaseID |
| 24 | 24 | */ |
| 25 | -class RollbackStep extends LongRunningPipelineStep |
|
| 26 | -{ |
|
| 25 | +class RollbackStep extends LongRunningPipelineStep { |
|
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * @var array |
@@ -43,8 +42,7 @@ discard block |
||
| 43 | 42 | /** |
| 44 | 43 | * @return string |
| 45 | 44 | */ |
| 46 | - public function getTitle() |
|
| 47 | - { |
|
| 45 | + public function getTitle() { |
|
| 48 | 46 | // Make sure the title includes the subtask |
| 49 | 47 | return parent::getTitle() . ":{$this->Doing}"; |
| 50 | 48 | } |
@@ -52,8 +50,7 @@ discard block |
||
| 52 | 50 | /** |
| 53 | 51 | * @return bool|null |
| 54 | 52 | */ |
| 55 | - public function start() |
|
| 56 | - { |
|
| 53 | + public function start() { |
|
| 57 | 54 | parent::start(); |
| 58 | 55 | |
| 59 | 56 | switch ($this->Status) { |
@@ -84,8 +81,7 @@ discard block |
||
| 84 | 81 | * |
| 85 | 82 | * @return boolean |
| 86 | 83 | */ |
| 87 | - protected function startRevertDeploy() |
|
| 88 | - { |
|
| 84 | + protected function startRevertDeploy() { |
|
| 89 | 85 | $this->Status = 'Started'; |
| 90 | 86 | $this->Doing = 'Deployment'; |
| 91 | 87 | $this->log("{$this->Title} starting revert deployment"); |
@@ -128,8 +124,7 @@ discard block |
||
| 128 | 124 | * |
| 129 | 125 | * @return bool True if success |
| 130 | 126 | */ |
| 131 | - protected function startRevertDatabase() |
|
| 132 | - { |
|
| 127 | + protected function startRevertDatabase() { |
|
| 133 | 128 | // Mark self as creating a snapshot |
| 134 | 129 | $this->Status = 'Started'; |
| 135 | 130 | $this->Doing = 'Snapshot'; |
@@ -171,8 +166,7 @@ discard block |
||
| 171 | 166 | /** |
| 172 | 167 | * Check status of current snapshot |
| 173 | 168 | */ |
| 174 | - protected function continueRevertDatabase() |
|
| 175 | - { |
|
| 169 | + protected function continueRevertDatabase() { |
|
| 176 | 170 | $this->log("Checking status of {$this->Title}..."); |
| 177 | 171 | |
| 178 | 172 | // Skip snapshot for dry run |
@@ -205,8 +199,7 @@ discard block |
||
| 205 | 199 | * |
| 206 | 200 | * @return boolean |
| 207 | 201 | */ |
| 208 | - protected function continueRevertDeploy() |
|
| 209 | - { |
|
| 202 | + protected function continueRevertDeploy() { |
|
| 210 | 203 | $this->log("Checking status of {$this->Title}..."); |
| 211 | 204 | |
| 212 | 205 | // Skip deployment for dry run |
@@ -246,8 +239,7 @@ discard block |
||
| 246 | 239 | * |
| 247 | 240 | * @return boolean |
| 248 | 241 | */ |
| 249 | - protected function doRestoreDB() |
|
| 250 | - { |
|
| 242 | + protected function doRestoreDB() { |
|
| 251 | 243 | return $this->getConfigSetting('RestoreDB') && $this->Pipeline()->PreviousSnapshot(); |
| 252 | 244 | } |
| 253 | 245 | |
@@ -257,8 +249,7 @@ discard block |
||
| 257 | 249 | * @param string $status Resque task status |
| 258 | 250 | * @return boolean True if the task is finished successfully |
| 259 | 251 | */ |
| 260 | - protected function checkResqueStatus($status) |
|
| 261 | - { |
|
| 252 | + protected function checkResqueStatus($status) { |
|
| 262 | 253 | switch ($status) { |
| 263 | 254 | case "Complete": |
| 264 | 255 | return true; |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | * @package deploynaut |
| 45 | 45 | * @subpackage pipeline |
| 46 | 46 | */ |
| 47 | -class SmokeTestPipelineStep extends PipelineStep |
|
| 48 | -{ |
|
| 47 | +class SmokeTestPipelineStep extends PipelineStep { |
|
| 49 | 48 | |
| 50 | 49 | /** |
| 51 | 50 | * Default config setting |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | * |
| 65 | 64 | * @return array List of tests |
| 66 | 65 | */ |
| 67 | - protected function getTests() |
|
| 68 | - { |
|
| 66 | + protected function getTests() { |
|
| 69 | 67 | // Get core tests |
| 70 | 68 | $tests = $this->getConfigSetting('Tests'); |
| 71 | 69 | |
@@ -99,8 +97,7 @@ discard block |
||
| 99 | 97 | * |
| 100 | 98 | * @return resource Curl handle |
| 101 | 99 | */ |
| 102 | - protected function initCurl() |
|
| 103 | - { |
|
| 100 | + protected function initCurl() { |
|
| 104 | 101 | $handle = curl_init(); |
| 105 | 102 | |
| 106 | 103 | // avoid curl_exec pushing out the response to the screen |
@@ -125,8 +122,7 @@ discard block |
||
| 125 | 122 | * @param array $test Test data |
| 126 | 123 | * @return bool success |
| 127 | 124 | */ |
| 128 | - public function runTest($ch, $name, $test) |
|
| 129 | - { |
|
| 125 | + public function runTest($ch, $name, $test) { |
|
| 130 | 126 | $this->log(sprintf('Starting smoke test "%s" to URL %s', $name, $test['URL'])); |
| 131 | 127 | curl_setopt($ch, CURLOPT_URL, $test['URL']); |
| 132 | 128 | |
@@ -203,8 +199,7 @@ discard block |
||
| 203 | 199 | return false; |
| 204 | 200 | } |
| 205 | 201 | |
| 206 | - public function start() |
|
| 207 | - { |
|
| 202 | + public function start() { |
|
| 208 | 203 | $this->Status = 'Started'; |
| 209 | 204 | $this->log("Starting {$this->Title}..."); |
| 210 | 205 | $this->write(); |
@@ -236,8 +231,7 @@ discard block |
||
| 236 | 231 | return $success; |
| 237 | 232 | } |
| 238 | 233 | |
| 239 | - public function markFailed($notify = true) |
|
| 240 | - { |
|
| 234 | + public function markFailed($notify = true) { |
|
| 241 | 235 | if ($this->getDryRun()) { |
| 242 | 236 | $this->log("[Skipped] Smoke testing failed: Putting up emergency maintenance page"); |
| 243 | 237 | } else { |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | * @package deploynaut |
| 23 | 23 | * @subpackage pipeline |
| 24 | 24 | */ |
| 25 | -class TriggerDeployStep extends LongRunningPipelineStep |
|
| 26 | -{ |
|
| 25 | +class TriggerDeployStep extends LongRunningPipelineStep { |
|
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * @var array |
@@ -43,8 +42,7 @@ discard block |
||
| 43 | 42 | /** |
| 44 | 43 | * @return bool |
| 45 | 44 | */ |
| 46 | - public function start() |
|
| 47 | - { |
|
| 45 | + public function start() { |
|
| 48 | 46 | // Just in case this step is being mistakenly restarted |
| 49 | 47 | if (!empty($this->Deployed)) { |
| 50 | 48 | $this->log(_t('TriggerDeployStep.BEENDEPLOYED', |
@@ -82,8 +80,7 @@ discard block |
||
| 82 | 80 | * @param Member|null $member |
| 83 | 81 | * @return boolean |
| 84 | 82 | */ |
| 85 | - public function canTriggerDeploy($member = null) |
|
| 86 | - { |
|
| 83 | + public function canTriggerDeploy($member = null) { |
|
| 87 | 84 | return $this->Pipeline()->Environment()->canDeploy($member); |
| 88 | 85 | } |
| 89 | 86 | |
@@ -92,8 +89,7 @@ discard block |
||
| 92 | 89 | * |
| 93 | 90 | * @return boolean True if successful |
| 94 | 91 | */ |
| 95 | - public function deploy() |
|
| 96 | - { |
|
| 92 | + public function deploy() { |
|
| 97 | 93 | // Check permission |
| 98 | 94 | if (!$this->canTriggerDeploy()) { |
| 99 | 95 | return Security::permissionFailure( |
@@ -118,8 +114,7 @@ discard block |
||
| 118 | 114 | /** |
| 119 | 115 | * Initiate the deployment process |
| 120 | 116 | */ |
| 121 | - public function StartDeployment() |
|
| 122 | - { |
|
| 117 | + public function StartDeployment() { |
|
| 123 | 118 | $this->Status = 'Started'; |
| 124 | 119 | if (!$this->Started) { |
| 125 | 120 | $this->Started = SS_Datetime::now()->Rfc2822(); |
@@ -129,8 +124,7 @@ discard block |
||
| 129 | 124 | return true; |
| 130 | 125 | } |
| 131 | 126 | |
| 132 | - public function getRunningDescription() |
|
| 133 | - { |
|
| 127 | + public function getRunningDescription() { |
|
| 134 | 128 | // Don't show options if this step has already been confirmed |
| 135 | 129 | if ($this->Deployed) { |
| 136 | 130 | return; |
@@ -140,8 +134,7 @@ discard block |
||
| 140 | 134 | 'Please press the "Deploy" button to continue deployment'); |
| 141 | 135 | } |
| 142 | 136 | |
| 143 | - public function allowedActions() |
|
| 144 | - { |
|
| 137 | + public function allowedActions() { |
|
| 145 | 138 | // Don't show options if this step has already been confirmed or can't be confirmed |
| 146 | 139 | if (!$this->canTriggerDeploy()) { |
| 147 | 140 | return parent::allowedActions(); |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | * @package deploynaut |
| 53 | 53 | * @subpackage pipeline |
| 54 | 54 | */ |
| 55 | -class UserConfirmationStep extends LongRunningPipelineStep |
|
| 56 | -{ |
|
| 55 | +class UserConfirmationStep extends LongRunningPipelineStep { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * Messages |
@@ -120,8 +119,7 @@ discard block |
||
| 120 | 119 | * |
| 121 | 120 | * @param ConfirmationMessagingService $service |
| 122 | 121 | */ |
| 123 | - public function setMessagingService(ConfirmationMessagingService $service) |
|
| 124 | - { |
|
| 122 | + public function setMessagingService(ConfirmationMessagingService $service) { |
|
| 125 | 123 | $this->messagingService = $service; |
| 126 | 124 | } |
| 127 | 125 | |
@@ -130,8 +128,7 @@ discard block |
||
| 130 | 128 | * |
| 131 | 129 | * @return ConfirmationMessagingService |
| 132 | 130 | */ |
| 133 | - public function getMessagingService() |
|
| 134 | - { |
|
| 131 | + public function getMessagingService() { |
|
| 135 | 132 | return $this->messagingService; |
| 136 | 133 | } |
| 137 | 134 | |
@@ -140,13 +137,11 @@ discard block |
||
| 140 | 137 | * |
| 141 | 138 | * @return boolean |
| 142 | 139 | */ |
| 143 | - public function hasResponse() |
|
| 144 | - { |
|
| 140 | + public function hasResponse() { |
|
| 145 | 141 | return $this->Approval !== 'None'; |
| 146 | 142 | } |
| 147 | 143 | |
| 148 | - public function start() |
|
| 149 | - { |
|
| 144 | + public function start() { |
|
| 150 | 145 | parent::start(); |
| 151 | 146 | |
| 152 | 147 | // Just in case this step is being mistakenly restarted |
@@ -175,8 +170,7 @@ discard block |
||
| 175 | 170 | * @param Member|null $member |
| 176 | 171 | * @return boolean |
| 177 | 172 | */ |
| 178 | - public function canApprove($member = null) |
|
| 179 | - { |
|
| 173 | + public function canApprove($member = null) { |
|
| 180 | 174 | return $this->Pipeline()->Environment()->canApprove($member); |
| 181 | 175 | } |
| 182 | 176 | |
@@ -185,8 +179,7 @@ discard block |
||
| 185 | 179 | * |
| 186 | 180 | * @return boolean True if successful |
| 187 | 181 | */ |
| 188 | - public function approve() |
|
| 189 | - { |
|
| 182 | + public function approve() { |
|
| 190 | 183 | // Check permission |
| 191 | 184 | if (!$this->canApprove()) { |
| 192 | 185 | return Security::permissionFailure( |
@@ -214,8 +207,7 @@ discard block |
||
| 214 | 207 | * |
| 215 | 208 | * @return boolean True if successful |
| 216 | 209 | */ |
| 217 | - public function reject() |
|
| 218 | - { |
|
| 210 | + public function reject() { |
|
| 219 | 211 | // Check permission |
| 220 | 212 | if (!$this->canApprove()) { |
| 221 | 213 | return Security::permissionFailure( |
@@ -243,8 +235,7 @@ discard block |
||
| 243 | 235 | * |
| 244 | 236 | * @return boolean True if not failed |
| 245 | 237 | */ |
| 246 | - protected function checkStatus() |
|
| 247 | - { |
|
| 238 | + protected function checkStatus() { |
|
| 248 | 239 | // For running or queued tasks ensure that we have not exceeded |
| 249 | 240 | // a reasonable time-elapsed to consider this job inactive |
| 250 | 241 | if ($this->isTimedOut()) { |
@@ -289,8 +280,7 @@ discard block |
||
| 289 | 280 | /** |
| 290 | 281 | * Initiate the approval process |
| 291 | 282 | */ |
| 292 | - public function startApproval() |
|
| 293 | - { |
|
| 283 | + public function startApproval() { |
|
| 294 | 284 | $this->Status = 'Started'; |
| 295 | 285 | $this->log("Starting {$this->Title}..."); |
| 296 | 286 | // Determine if we should use delayed notification |
@@ -311,8 +301,7 @@ discard block |
||
| 311 | 301 | * @param string $messageID Message ID |
| 312 | 302 | * @return array Resulting array(subject, message) |
| 313 | 303 | */ |
| 314 | - protected function generateMessageTemplate($role, $messageID) |
|
| 315 | - { |
|
| 304 | + protected function generateMessageTemplate($role, $messageID) { |
|
| 316 | 305 | $subject = $this->getConfigSetting('Subjects', "$messageID-$role") |
| 317 | 306 | ?: $this->getConfigSetting('Subjects', $messageID); |
| 318 | 307 | $message = $this->getConfigSetting('Messages', "$messageID-$role") |
@@ -328,8 +317,7 @@ discard block |
||
| 328 | 317 | * |
| 329 | 318 | * @return array |
| 330 | 319 | */ |
| 331 | - public function getReplacements() |
|
| 332 | - { |
|
| 320 | + public function getReplacements() { |
|
| 333 | 321 | // Get member who began this request |
| 334 | 322 | return array_merge( |
| 335 | 323 | $this->Pipeline()->getReplacements(), |
@@ -349,8 +337,7 @@ discard block |
||
| 349 | 337 | * This is used for delayed notification so that failover recipients can be notified. |
| 350 | 338 | * @return boolean|null True if successful |
| 351 | 339 | */ |
| 352 | - protected function sendMessage($messageID, $recipientGroup = 'all') |
|
| 353 | - { |
|
| 340 | + protected function sendMessage($messageID, $recipientGroup = 'all') { |
|
| 354 | 341 | // Add additionally configured arguments |
| 355 | 342 | $arguments = $this->getConfigSetting('ServiceArguments') ?: array(); |
| 356 | 343 | |
@@ -389,8 +376,7 @@ discard block |
||
| 389 | 376 | } |
| 390 | 377 | } |
| 391 | 378 | |
| 392 | - public function getRunningDescription() |
|
| 393 | - { |
|
| 379 | + public function getRunningDescription() { |
|
| 394 | 380 | |
| 395 | 381 | // Don't show options if this step has already been confirmed |
| 396 | 382 | if ($this->hasResponse() || !$this->isRunning()) { |
@@ -400,8 +386,7 @@ discard block |
||
| 400 | 386 | return 'This deployment is currently awaiting approval before it can complete.'; |
| 401 | 387 | } |
| 402 | 388 | |
| 403 | - public function allowedActions() |
|
| 404 | - { |
|
| 389 | + public function allowedActions() { |
|
| 405 | 390 | // Don't show options if this step has already been confirmed or can't be confirmed |
| 406 | 391 | if ($this->hasResponse() || !$this->isRunning() || !$this->canApprove()) { |
| 407 | 392 | return parent::allowedActions(); |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | * Used in the Resque report admin |
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | -class ResqueJob extends ViewableData |
|
| 10 | -{ |
|
| 9 | +class ResqueJob extends ViewableData { |
|
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * @var array |
@@ -17,48 +16,42 @@ discard block |
||
| 17 | 16 | /** |
| 18 | 17 | * @param array $data |
| 19 | 18 | */ |
| 20 | - public function __construct($data = array()) |
|
| 21 | - { |
|
| 19 | + public function __construct($data = array()) { |
|
| 22 | 20 | $this->record = $data; |
| 23 | 21 | } |
| 24 | 22 | |
| 25 | 23 | /** |
| 26 | 24 | * @return string |
| 27 | 25 | */ |
| 28 | - public function i18n_singular_name() |
|
| 29 | - { |
|
| 26 | + public function i18n_singular_name() { |
|
| 30 | 27 | return 'Resque queue'; |
| 31 | 28 | } |
| 32 | 29 | |
| 33 | 30 | /** |
| 34 | 31 | * @return boolean |
| 35 | 32 | */ |
| 36 | - public function canView() |
|
| 37 | - { |
|
| 33 | + public function canView() { |
|
| 38 | 34 | return true; |
| 39 | 35 | } |
| 40 | 36 | |
| 41 | 37 | /** |
| 42 | 38 | * @return bool |
| 43 | 39 | */ |
| 44 | - public function canEdit() |
|
| 45 | - { |
|
| 40 | + public function canEdit() { |
|
| 46 | 41 | return false; |
| 47 | 42 | } |
| 48 | 43 | |
| 49 | 44 | /** |
| 50 | 45 | * @return bool |
| 51 | 46 | */ |
| 52 | - public function candelete() |
|
| 53 | - { |
|
| 47 | + public function candelete() { |
|
| 54 | 48 | return false; |
| 55 | 49 | } |
| 56 | 50 | |
| 57 | 51 | /** |
| 58 | 52 | * @return bool |
| 59 | 53 | */ |
| 60 | - public function cancreate() |
|
| 61 | - { |
|
| 54 | + public function cancreate() { |
|
| 62 | 55 | return false; |
| 63 | 56 | } |
| 64 | 57 | |
@@ -66,8 +59,7 @@ discard block |
||
| 66 | 59 | * @param string $property |
| 67 | 60 | * @return mixed |
| 68 | 61 | */ |
| 69 | - public function __get($property) |
|
| 70 | - { |
|
| 62 | + public function __get($property) { |
|
| 71 | 63 | if (isset($this->record[$property])) { |
| 72 | 64 | return $this->record[$property]; |
| 73 | 65 | } |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | * @property string $Name |
| 9 | 9 | * @property int $Size |
| 10 | 10 | */ |
| 11 | -class ResqueQueue extends ViewableData |
|
| 12 | -{ |
|
| 11 | +class ResqueQueue extends ViewableData { |
|
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | 14 | * @var array |
@@ -19,16 +18,14 @@ discard block |
||
| 19 | 18 | /** |
| 20 | 19 | * @param array $data |
| 21 | 20 | */ |
| 22 | - public function __construct($data = array()) |
|
| 23 | - { |
|
| 21 | + public function __construct($data = array()) { |
|
| 24 | 22 | $this->record = $data; |
| 25 | 23 | } |
| 26 | 24 | |
| 27 | 25 | /** |
| 28 | 26 | * @return \FieldList |
| 29 | 27 | */ |
| 30 | - public function getCMSFields() |
|
| 31 | - { |
|
| 28 | + public function getCMSFields() { |
|
| 32 | 29 | $fieldList = new FieldList(); |
| 33 | 30 | $fieldList->push(new ReadonlyField('Name', 'Name', $this->Name)); |
| 34 | 31 | $fieldList->push(new ReadonlyField('Size', 'Size', $this->Size)); |
@@ -45,13 +42,11 @@ discard block |
||
| 45 | 42 | /** |
| 46 | 43 | * @return string |
| 47 | 44 | */ |
| 48 | - public function i18n_singular_name() |
|
| 49 | - { |
|
| 45 | + public function i18n_singular_name() { |
|
| 50 | 46 | return 'Resque queue'; |
| 51 | 47 | } |
| 52 | 48 | |
| 53 | - protected function getJobs() |
|
| 54 | - { |
|
| 49 | + protected function getJobs() { |
|
| 55 | 50 | $jobs = new ArrayList(); |
| 56 | 51 | |
| 57 | 52 | $resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1); |
@@ -86,32 +81,28 @@ discard block |
||
| 86 | 81 | /** |
| 87 | 82 | * @return boolean |
| 88 | 83 | */ |
| 89 | - public function canView() |
|
| 90 | - { |
|
| 84 | + public function canView() { |
|
| 91 | 85 | return true; |
| 92 | 86 | } |
| 93 | 87 | |
| 94 | 88 | /** |
| 95 | 89 | * @return bool |
| 96 | 90 | */ |
| 97 | - public function canEdit() |
|
| 98 | - { |
|
| 91 | + public function canEdit() { |
|
| 99 | 92 | return true; |
| 100 | 93 | } |
| 101 | 94 | |
| 102 | 95 | /** |
| 103 | 96 | * @return bool |
| 104 | 97 | */ |
| 105 | - public function candelete() |
|
| 106 | - { |
|
| 98 | + public function candelete() { |
|
| 107 | 99 | return false; |
| 108 | 100 | } |
| 109 | 101 | |
| 110 | 102 | /** |
| 111 | 103 | * @return bool |
| 112 | 104 | */ |
| 113 | - public function cancreate() |
|
| 114 | - { |
|
| 105 | + public function cancreate() { |
|
| 115 | 106 | return false; |
| 116 | 107 | } |
| 117 | 108 | |
@@ -119,8 +110,7 @@ discard block |
||
| 119 | 110 | * @param string $property |
| 120 | 111 | * @return mixed |
| 121 | 112 | */ |
| 122 | - public function __get($property) |
|
| 123 | - { |
|
| 113 | + public function __get($property) { |
|
| 124 | 114 | if (isset($this->record[$property])) { |
| 125 | 115 | return $this->record[$property]; |
| 126 | 116 | } |