Completed
Pull Request — master (#489)
by Helpful
03:51
created
code/model/DNData.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         parent::__construct();
56 56
 
57 57
         // Better to use injector to set these
58
-        if (func_num_args() == 0) {
58
+        if(func_num_args() == 0) {
59 59
             return;
60 60
         }
61 61
         Deprecation::notice(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function setEnvironmentDir($environmentDir)
87 87
     {
88
-        if ($environmentDir[0] != "/") {
88
+        if($environmentDir[0] != "/") {
89 89
             $environmentDir = BASE_PATH . '/' . $environmentDir;
90 90
         }
91 91
         $this->environmentDir = realpath($environmentDir) ?: $environmentDir;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function setKeyDir($keyDir)
110 110
     {
111
-        if ($keyDir[0] != "/") {
111
+        if($keyDir[0] != "/") {
112 112
             $keyDir = BASE_PATH . '/' . $keyDir;
113 113
         }
114 114
         $this->keyDir = realpath($keyDir) ?: $keyDir;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function setDataTransferDir($transferDir)
156 156
     {
157
-        if ($transferDir[0] != "/") {
157
+        if($transferDir[0] != "/") {
158 158
             $transferDir = BASE_PATH . '/' . $transferDir;
159 159
         }
160
-        if (strpos($transferDir, ASSETS_PATH) === false) {
160
+        if(strpos($transferDir, ASSETS_PATH) === false) {
161 161
             throw new LogicException(sprintf(
162 162
                 'DNData::dataTransferDir needs to be located within <webroot>assets/ (location: %s)',
163 163
                 $transferDir
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
     public function getProjectPaths()
187 187
     {
188 188
         $paths = array();
189
-        if (!file_exists($this->getEnvironmentDir())) {
189
+        if(!file_exists($this->getEnvironmentDir())) {
190 190
             $eMessage = 'The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it '
191 191
             . 'first and add some projects to it.';
192 192
             throw new Exception($eMessage);
193 193
         }
194
-        foreach (scandir($this->getEnvironmentDir()) as $project) {
194
+        foreach(scandir($this->getEnvironmentDir()) as $project) {
195 195
             // Exlcude dot-prefixed directories (.git was getting in the way)
196
-            if (preg_match('/^[^\.]/', $project)) {
196
+            if(preg_match('/^[^\.]/', $project)) {
197 197
                 $path = $this->getEnvironmentDir() . '/' . $project;
198
-                if (is_dir($path) && $project != '.' && $project != '..') {
198
+                if(is_dir($path) && $project != '.' && $project != '..') {
199 199
                     $paths[] = $project;
200 200
                 }
201 201
             }
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
         $baseDir = $this->getEnvironmentDir() . '/' . $project;
214 214
 
215 215
         $paths = array();
216
-        if (!file_exists($baseDir)) {
216
+        if(!file_exists($baseDir)) {
217 217
             throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.');
218 218
         }
219 219
         // Search the directory for config files.
220
-        foreach (scandir($baseDir) as $environmentFile) {
221
-            if (preg_match('/\.rb$/', $environmentFile)) {
220
+        foreach(scandir($baseDir) as $environmentFile) {
221
+            if(preg_match('/\.rb$/', $environmentFile)) {
222 222
                 // Config found, wrap it into an object.
223 223
                 $paths[] = "$baseDir/$environmentFile";
224 224
             }
Please login to merge, or discard this patch.
code/model/DNDataArchive.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function onBeforeWrite()
129 129
     {
130
-        if (!$this->AuthorID) {
130
+        if(!$this->AuthorID) {
131 131
             $this->AuthorID = Member::currentUserID();
132 132
         }
133 133
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function FileSize()
191 191
     {
192
-        if ($this->ArchiveFile()->exists()) {
192
+        if($this->ArchiveFile()->exists()) {
193 193
             return $this->ArchiveFile()->getSize();
194 194
         } else {
195 195
             return "N/A";
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     public function getModeNice()
200 200
     {
201
-        if ($this->Mode == 'all') {
201
+        if($this->Mode == 'all') {
202 202
             return 'database and assets';
203 203
         } else {
204 204
             return $this->Mode;
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
     public function canRestore($member = null)
238 238
     {
239 239
         $memberID = $member ? $member->ID : Member::currentUserID();
240
-        if (!$memberID) {
240
+        if(!$memberID) {
241 241
             return false;
242 242
         }
243 243
 
244 244
         $key = $memberID . '-' . $this->EnvironmentID;
245
-        if (!isset(self::$_cache_can_restore[$key])) {
245
+        if(!isset(self::$_cache_can_restore[$key])) {
246 246
             self::$_cache_can_restore[$key] = $this->Environment()->canUploadArchive($member);
247 247
         }
248 248
 
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
     public function canDownload($member = null)
260 260
     {
261 261
         $memberID = $member ? $member->ID : Member::currentUserID();
262
-        if (!$memberID) {
262
+        if(!$memberID) {
263 263
             return false;
264 264
         }
265 265
 
266 266
         $key = $memberID . '-' . $this->EnvironmentID;
267
-        if (!isset(self::$_cache_can_download[$key])) {
267
+        if(!isset(self::$_cache_can_download[$key])) {
268 268
             self::$_cache_can_download[$key] = $this->Environment()->canDownloadArchive($member);
269 269
         }
270 270
         return self::$_cache_can_download[$key];
@@ -291,27 +291,27 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function canMoveTo($targetEnv, $member = null)
293 293
     {
294
-        if ($this->Environment()->Project()->ID != $targetEnv->Project()->ID) {
294
+        if($this->Environment()->Project()->ID != $targetEnv->Project()->ID) {
295 295
             // We don't permit moving snapshots between projects at this stage.
296 296
             return false;
297 297
         }
298 298
 
299
-        if (!$member) {
299
+        if(!$member) {
300 300
             $member = Member::currentUser();
301 301
         }
302 302
 
303 303
         // Must be logged in to check permissions
304
-        if (!$member) {
304
+        if(!$member) {
305 305
             return false;
306 306
         }
307 307
 
308 308
         // Admin can always move.
309
-        if (Permission::checkMember($member, 'ADMIN')) {
309
+        if(Permission::checkMember($member, 'ADMIN')) {
310 310
             return true;
311 311
         }
312 312
 
313 313
         // Checks if the user can actually access the archive.
314
-        if (!$this->canDownload($member)) {
314
+        if(!$this->canDownload($member)) {
315 315
             return false;
316 316
         }
317 317
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     {
332 332
         $archive = $this;
333 333
         $envs = $this->Environment()->Project()->DNEnvironmentList()
334
-            ->filterByCallback(function ($item) use ($archive) {
334
+            ->filterByCallback(function($item) use ($archive) {
335 335
                 return $archive->EnvironmentID != $item->ID && $archive->canMoveTo($item);
336 336
             });
337 337
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         // Note that with CapistranoDeploymentBackend the file won't be available yet, as it
413 413
         // gets put in place immediately after this method gets called. In which case, it will
414 414
         // be hashed in setArchiveFromFiles()
415
-        if (file_exists($file->FullPath)) {
415
+        if(file_exists($file->FullPath)) {
416 416
             $this->ArchiveFileHash = md5_file($file->FullPath);
417 417
         }
418 418
         $this->ArchiveFileID = $file->ID;
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
      */
434 434
     public function extractArchive($workingDir = null)
435 435
     {
436
-        if (!is_dir($workingDir)) {
436
+        if(!is_dir($workingDir)) {
437 437
             mkdir($workingDir, 0700, true);
438 438
         }
439 439
 
440
-        $cleanupFn = function () use ($workingDir) {
440
+        $cleanupFn = function() use ($workingDir) {
441 441
             $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir)));
442 442
             $process->run();
443 443
         };
@@ -451,28 +451,28 @@  discard block
 block discarded – undo
451 451
         ));
452 452
         $process->setTimeout(3600);
453 453
         $process->run();
454
-        if (!$process->isSuccessful()) {
454
+        if(!$process->isSuccessful()) {
455 455
             $cleanupFn();
456 456
             throw new RuntimeException(sprintf('Could not extract the sspak file: %s', $process->getErrorOutput()));
457 457
         }
458 458
 
459 459
         // Extract database.sql.gz to <workingdir>/database.sql
460
-        if (file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) {
460
+        if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) {
461 461
             $process = new Process('gunzip database.sql.gz', $workingDir);
462 462
             $process->setTimeout(3600);
463 463
             $process->run();
464
-            if (!$process->isSuccessful()) {
464
+            if(!$process->isSuccessful()) {
465 465
                 $cleanupFn();
466 466
                 throw new RuntimeException(sprintf('Could not extract the db archive: %s', $process->getErrorOutput()));
467 467
             }
468 468
         }
469 469
 
470 470
         // Extract assets.tar.gz to <workingdir>/assets/
471
-        if (file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) {
471
+        if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) {
472 472
             $process = new Process('tar xzf assets.tar.gz', $workingDir);
473 473
             $process->setTimeout(3600);
474 474
             $process->run();
475
-            if (!$process->isSuccessful()) {
475
+            if(!$process->isSuccessful()) {
476 476
                 $cleanupFn();
477 477
                 throw new RuntimeException(sprintf('Could not extract the assets archive: %s', $process->getErrorOutput()));
478 478
             }
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
         $file = $this->ArchiveFile()->FullPath;
499 499
 
500
-        if (!is_readable($file)) {
500
+        if(!is_readable($file)) {
501 501
             $result->error(sprintf('SSPak file "%s" cannot be read.', $file));
502 502
             return $result;
503 503
         }
@@ -505,19 +505,19 @@  discard block
 block discarded – undo
505 505
         $process = new Process(sprintf('tar -tf %s', escapeshellarg($file)));
506 506
         $process->setTimeout(120);
507 507
         $process->run();
508
-        if (!$process->isSuccessful()) {
508
+        if(!$process->isSuccessful()) {
509 509
             throw new RuntimeException(sprintf('Could not list files in archive: %s', $process->getErrorOutput()));
510 510
         }
511 511
 
512 512
         $output = explode(PHP_EOL, $process->getOutput());
513 513
         $files = array_filter($output);
514 514
 
515
-        if (in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) {
515
+        if(in_array($mode, array('all', 'db')) && !in_array('database.sql.gz', $files)) {
516 516
             $result->error('The snapshot is missing the database.');
517 517
             return $result;
518 518
         }
519 519
 
520
-        if (in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) {
520
+        if(in_array($mode, array('all', 'assets')) && !in_array('assets.tar.gz', $files)) {
521 521
             $result->error('The snapshot is missing assets.');
522 522
             return $result;
523 523
         }
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
             sprintf('find %s -type f -exec chmod 644 {} +', escapeshellarg($workingDir))
549 549
         );
550 550
 
551
-        foreach ($fixCmds as $cmd) {
551
+        foreach($fixCmds as $cmd) {
552 552
             $process = new Process($cmd);
553 553
             $process->setTimeout(3600);
554 554
             $process->run();
555
-            if (!$process->isSuccessful()) {
555
+            if(!$process->isSuccessful()) {
556 556
                 throw new RuntimeException($process->getErrorOutput());
557 557
             }
558 558
         }
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
     public function setArchiveFromFiles($workingDir)
571 571
     {
572 572
         $command = sprintf('sspak saveexisting %s 2>&1', $this->ArchiveFile()->FullPath);
573
-        if ($this->Mode == 'db') {
573
+        if($this->Mode == 'db') {
574 574
             $command .= sprintf(' --db=%s/database.sql', $workingDir);
575
-        } elseif ($this->Mode == 'assets') {
575
+        } elseif($this->Mode == 'assets') {
576 576
             $command .= sprintf(' --assets=%s/assets', $workingDir);
577 577
         } else {
578 578
             $command .= sprintf(' --db=%s/database.sql --assets=%s/assets', $workingDir, $workingDir);
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         $process = new Process($command, $workingDir);
582 582
         $process->setTimeout(3600);
583 583
         $process->run();
584
-        if (!$process->isSuccessful()) {
584
+        if(!$process->isSuccessful()) {
585 585
             throw new RuntimeException($process->getErrorOutput());
586 586
         }
587 587
 
Please login to merge, or discard this patch.
code/model/DNEnvironment.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function Backend()
192 192
     {
193 193
         $backends = array_keys($this->config()->get('allowed_backends', Config::FIRST_SET));
194
-        switch (sizeof($backends)) {
194
+        switch(sizeof($backends)) {
195 195
         // Nothing allowed, use the default value "DeploymentBackend"
196 196
             case 0:
197 197
                 $backend = "DeploymentBackend";
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list
206 206
             default:
207 207
                 $backend = $this->BackendIdentifier;
208
-                if (!in_array($backend, $backends)) {
208
+                if(!in_array($backend, $backends)) {
209 209
                     $backend = $backends[0];
210 210
                 }
211 211
         }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     public function getBareURL()
256 256
     {
257 257
         $url = parse_url($this->URL);
258
-        if (isset($url['host'])) {
258
+        if(isset($url['host'])) {
259 259
             return strtolower($url['host']);
260 260
         }
261 261
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     public function GenericPipelineConfig()
291 291
     {
292 292
         $config = $this->loadPipelineConfig();
293
-        if ($config) {
293
+        if($config) {
294 294
             return self::array_to_viewabledata($config);
295 295
         }
296 296
     }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
         require_once 'thirdparty/spyc/spyc.php';
306 306
 
307 307
         $path = $this->getPipelineFilename();
308
-        if (file_exists($path)) {
308
+        if(file_exists($path)) {
309 309
             return Spyc::YAMLLoad($path);
310 310
         }
311 311
     }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public function DependsOnEnvironment()
320 320
     {
321
-        if ($this->HasPipelineSupport()) {
321
+        if($this->HasPipelineSupport()) {
322 322
             $pipeline = $this->GenericPipeline();
323 323
             return $pipeline->getDependentEnvironment();
324 324
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     public function CanCancelPipeline()
352 352
     {
353 353
         // do we have a current pipeline
354
-        if ($this->HasCurrentPipeline()) {
354
+        if($this->HasCurrentPipeline()) {
355 355
             return $this->CurrentPipeline()->canAbort();
356 356
         }
357 357
         return false;
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function canView($member = null)
367 367
     {
368
-        if (!$member) {
368
+        if(!$member) {
369 369
             $member = Member::currentUser();
370 370
         }
371
-        if (!$member) {
371
+        if(!$member) {
372 372
             return false;
373 373
         }
374 374
         // Must be logged in to check permissions
375 375
 
376
-        if (Permission::checkMember($member, 'ADMIN')) {
376
+        if(Permission::checkMember($member, 'ADMIN')) {
377 377
             return true;
378 378
         }
379 379
 
380 380
         // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions
381
-        if ($this->Viewers()->exists() || $this->ViewerGroups()->exists()) {
381
+        if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) {
382 382
             return $this->Viewers()->byID($member->ID)
383 383
                 || $member->inGroups($this->ViewerGroups());
384 384
         }
@@ -394,20 +394,20 @@  discard block
 block discarded – undo
394 394
      */
395 395
     public function canDeploy($member = null)
396 396
     {
397
-        if (!$member) {
397
+        if(!$member) {
398 398
             $member = Member::currentUser();
399 399
         }
400
-        if (!$member) {
400
+        if(!$member) {
401 401
             return false;
402 402
         }
403 403
         // Must be logged in to check permissions
404 404
 
405
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
406
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) {
405
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
406
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) {
407 407
                 return true;
408 408
             }
409 409
         } else {
410
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) {
410
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) {
411 411
                 return true;
412 412
             }
413 413
         }
@@ -425,20 +425,20 @@  discard block
 block discarded – undo
425 425
      */
426 426
     public function canRestore($member = null)
427 427
     {
428
-        if (!$member) {
428
+        if(!$member) {
429 429
             $member = Member::currentUser();
430 430
         }
431
-        if (!$member) {
431
+        if(!$member) {
432 432
             return false;
433 433
         }
434 434
         // Must be logged in to check permissions
435 435
 
436
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
437
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
436
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
437
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
438 438
                 return true;
439 439
             }
440 440
         } else {
441
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
441
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
442 442
                 return true;
443 443
             }
444 444
         }
@@ -457,24 +457,24 @@  discard block
 block discarded – undo
457 457
     public function canBackup($member = null)
458 458
     {
459 459
         $project = $this->Project();
460
-        if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
460
+        if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
461 461
             return false;
462 462
         }
463 463
 
464
-        if (!$member) {
464
+        if(!$member) {
465 465
             $member = Member::currentUser();
466 466
         }
467 467
         // Must be logged in to check permissions
468
-        if (!$member) {
468
+        if(!$member) {
469 469
             return false;
470 470
         }
471 471
 
472
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
473
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
472
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
473
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
474 474
                 return true;
475 475
             }
476 476
         } else {
477
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
477
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
478 478
                 return true;
479 479
             }
480 480
         }
@@ -497,24 +497,24 @@  discard block
 block discarded – undo
497 497
     public function canUploadArchive($member = null)
498 498
     {
499 499
         $project = $this->Project();
500
-        if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
500
+        if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
501 501
             return false;
502 502
         }
503 503
 
504
-        if (!$member) {
504
+        if(!$member) {
505 505
             $member = Member::currentUser();
506 506
         }
507
-        if (!$member) {
507
+        if(!$member) {
508 508
             return false;
509 509
         }
510 510
         // Must be logged in to check permissions
511 511
 
512
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
513
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
512
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
513
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
514 514
                 return true;
515 515
             }
516 516
         } else {
517
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
517
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
518 518
                 return true;
519 519
             }
520 520
         }
@@ -532,20 +532,20 @@  discard block
 block discarded – undo
532 532
      */
533 533
     public function canDownloadArchive($member = null)
534 534
     {
535
-        if (!$member) {
535
+        if(!$member) {
536 536
             $member = Member::currentUser();
537 537
         }
538
-        if (!$member) {
538
+        if(!$member) {
539 539
             return false;
540 540
         }
541 541
         // Must be logged in to check permissions
542 542
 
543
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
544
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
543
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
544
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
545 545
                 return true;
546 546
             }
547 547
         } else {
548
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
548
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
549 549
                 return true;
550 550
             }
551 551
         }
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
      */
563 563
     public function canAbort($member = null)
564 564
     {
565
-        if (!$member) {
565
+        if(!$member) {
566 566
             $member = Member::currentUser();
567 567
         }
568
-        if (!$member) {
568
+        if(!$member) {
569 569
             return false;
570 570
         }
571 571
 
572
-        if (Permission::checkMember($member, 'ADMIN')) {
572
+        if(Permission::checkMember($member, 'ADMIN')) {
573 573
             return true;
574 574
         }
575 575
 
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function canApprove($member = null)
587 587
     {
588
-        if (!$member) {
588
+        if(!$member) {
589 589
             $member = Member::currentUser();
590 590
         }
591
-        if (!$member) {
591
+        if(!$member) {
592 592
             return false;
593 593
         }
594 594
 
595
-        if (Permission::checkMember($member, 'ADMIN')) {
595
+        if(Permission::checkMember($member, 'ADMIN')) {
596 596
             return true;
597 597
         }
598 598
         return $this->PipelineApprovers()->byID($member->ID)
@@ -608,20 +608,20 @@  discard block
 block discarded – undo
608 608
      */
609 609
     public function canDeleteArchive($member = null)
610 610
     {
611
-        if (!$member) {
611
+        if(!$member) {
612 612
             $member = Member::currentUser();
613 613
         }
614
-        if (!$member) {
614
+        if(!$member) {
615 615
             return false;
616 616
         }
617 617
         // Must be logged in to check permissions
618 618
 
619
-        if ($this->Usage==='Production' || $this->Usage==='Unspecified') {
620
-            if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
619
+        if($this->Usage === 'Production' || $this->Usage === 'Unspecified') {
620
+            if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
621 621
                 return true;
622 622
             }
623 623
         } else {
624
-            if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
624
+            if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
625 625
                 return true;
626 626
             }
627 627
         }
@@ -785,18 +785,18 @@  discard block
 block discarded – undo
785 785
             'Status' => 'Finished'
786 786
         ))->sort('LastEdited DESC')->first();
787 787
 
788
-        if (!$deploy || (!$deploy->SHA)) {
788
+        if(!$deploy || (!$deploy->SHA)) {
789 789
             return false;
790 790
         }
791 791
 
792 792
         $repo = $this->Project()->getRepository();
793
-        if (!$repo) {
793
+        if(!$repo) {
794 794
             return $deploy;
795 795
         }
796 796
 
797 797
         try {
798 798
             $commit = $repo->getCommit($deploy->SHA);
799
-            if ($commit) {
799
+            if($commit) {
800 800
                 $deploy->Message = Convert::raw2xml($commit->getMessage());
801 801
                 $deploy->Committer = Convert::raw2xml($commit->getCommitterName());
802 802
                 $deploy->CommitDate = $commit->getCommitterDate()->Format('d/m/Y g:ia');
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
                 $deploy->AuthorDate = $commit->getAuthorDate()->Format('d/m/Y g:ia');
805 805
             }
806 806
             // We can't find this SHA, so we ignore adding a commit message to the deployment
807
-        } catch (Exception $ex) {
807
+        } catch(Exception $ex) {
808 808
         }
809 809
 
810 810
         return $deploy;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
     {
831 831
         try {
832 832
             $repo = $this->Project()->getRepository();
833
-            if ($repo !== false) {
833
+            if($repo !== false) {
834 834
                 $commit = new \Gitonomy\Git\Commit($repo, $sha);
835 835
                 return [
836 836
                     'AuthorName' => (string)Convert::raw2xml($commit->getAuthorName()),
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
                     'Hash' => Convert::raw2xml($commit->getHash())
841 841
                 ];
842 842
             }
843
-        } catch (\Gitonomy\Git\Exception\ReferenceNotFoundException $exc) {
843
+        } catch(\Gitonomy\Git\Exception\ReferenceNotFoundException $exc) {
844 844
             SS_Log::log($exc, SS_Log::WARN);
845 845
         }
846 846
         return array(
@@ -915,12 +915,12 @@  discard block
 block discarded – undo
915 915
         $fields = new FieldList(new TabSet('Root'));
916 916
 
917 917
         $project = $this->Project();
918
-        if ($project && $project->exists()) {
918
+        if($project && $project->exists()) {
919 919
             $viewerGroups = $project->Viewers();
920 920
             $groups = $viewerGroups->sort('Title')->map()->toArray();
921 921
             $members = array();
922
-            foreach ($viewerGroups as $group) {
923
-                foreach ($group->Members()->map() as $k => $v) {
922
+            foreach($viewerGroups as $group) {
923
+                foreach($group->Members()->map() as $k => $v) {
924 924
                     $members[$k] = $v;
925 925
                 }
926 926
             }
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
         // Backend identifier - pick from a named list of configurations specified in YML config
958 958
         $backends = $this->config()->get('allowed_backends', Config::FIRST_SET);
959 959
         // If there's only 1 backend, then user selection isn't needed
960
-        if (sizeof($backends) > 1) {
960
+        if(sizeof($backends) > 1) {
961 961
             $fields->addFieldToTab('Root.Main', DropdownField::create('BackendIdentifier', 'Deployment backend')
962 962
                 ->setSource($backends)
963 963
                 ->setDescription('What kind of deployment system should be used to deploy to this environment'));
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
         ));
1038 1038
 
1039 1039
         // The Main.DeployConfig
1040
-        if ($this->Project()->exists()) {
1040
+        if($this->Project()->exists()) {
1041 1041
             $this->setDeployConfigurationFields($fields);
1042 1042
         }
1043 1043
 
1044 1044
         // The DataArchives
1045 1045
         $dataArchiveConfig = GridFieldConfig_RecordViewer::create();
1046 1046
         $dataArchiveConfig->removeComponentsByType('GridFieldAddNewButton');
1047
-        if (class_exists('GridFieldBulkManager')) {
1047
+        if(class_exists('GridFieldBulkManager')) {
1048 1048
             $dataArchiveConfig->addComponent(new GridFieldBulkManager());
1049 1049
         }
1050 1050
         $dataArchive = GridField::create('DataArchives', 'Data Archives', $this->DataArchives(), $dataArchiveConfig);
@@ -1054,10 +1054,10 @@  discard block
 block discarded – undo
1054 1054
         $this->setPipelineConfigurationFields($fields);
1055 1055
 
1056 1056
         // Pipelines
1057
-        if ($this->Pipelines()->Count()) {
1057
+        if($this->Pipelines()->Count()) {
1058 1058
             $pipelinesConfig = GridFieldConfig_RecordEditor::create();
1059 1059
             $pipelinesConfig->removeComponentsByType('GridFieldAddNewButton');
1060
-            if (class_exists('GridFieldBulkManager')) {
1060
+            if(class_exists('GridFieldBulkManager')) {
1061 1061
                 $pipelinesConfig->addComponent(new GridFieldBulkManager());
1062 1062
             }
1063 1063
             $pipelines = GridField::create('Pipelines', 'Pipelines', $this->Pipelines(), $pipelinesConfig);
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
         // Deployments
1068 1068
         $deploymentsConfig = GridFieldConfig_RecordEditor::create();
1069 1069
         $deploymentsConfig->removeComponentsByType('GridFieldAddNewButton');
1070
-        if (class_exists('GridFieldBulkManager')) {
1070
+        if(class_exists('GridFieldBulkManager')) {
1071 1071
             $deploymentsConfig->addComponent(new GridFieldBulkManager());
1072 1072
         }
1073 1073
         $deployments = GridField::create('Deployments', 'Deployments', $this->Deployments(), $deploymentsConfig);
@@ -1092,11 +1092,11 @@  discard block
 block discarded – undo
1092 1092
      */
1093 1093
     protected function setDeployConfigurationFields(&$fields)
1094 1094
     {
1095
-        if (!$this->config()->get('allow_web_editing')) {
1095
+        if(!$this->config()->get('allow_web_editing')) {
1096 1096
             return;
1097 1097
         }
1098 1098
 
1099
-        if ($this->envFileExists()) {
1099
+        if($this->envFileExists()) {
1100 1100
             $deployConfig = new TextareaField('DeployConfig', 'Deploy config', $this->getEnvironmentConfig());
1101 1101
             $deployConfig->setRows(40);
1102 1102
             $fields->insertAfter($deployConfig, 'Filename');
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
      */
1118 1118
     protected function setPipelineConfigurationFields($fields)
1119 1119
     {
1120
-        if (!$this->config()->get('allow_web_editing')) {
1120
+        if(!$this->config()->get('allow_web_editing')) {
1121 1121
             return;
1122 1122
         }
1123 1123
         $config = $this->pipelineFileExists()
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
             : '';
1126 1126
         $deployConfig = new TextareaField('PipelineConfig', 'Pipeline config', $config);
1127 1127
         $deployConfig->setRows(40);
1128
-        if (!$this->pipelineFileExists()) {
1128
+        if(!$this->pipelineFileExists()) {
1129 1129
             $deployConfig->setDescription(
1130 1130
                 "No pipeline is configured for this environment. Saving content here will generate a new template."
1131 1131
             );
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
     public function onBeforeWrite()
1148 1148
     {
1149 1149
         parent::onBeforeWrite();
1150
-        if ($this->Name && $this->Name . '.rb' != $this->Filename) {
1150
+        if($this->Name && $this->Name . '.rb' != $this->Filename) {
1151 1151
             $this->Filename = $this->Name . '.rb';
1152 1152
         }
1153 1153
         $this->checkEnvironmentPath();
@@ -1159,13 +1159,13 @@  discard block
 block discarded – undo
1159 1159
     {
1160 1160
         parent::onAfterWrite();
1161 1161
 
1162
-        if ($this->Usage == 'Production' || $this->Usage == 'UAT') {
1162
+        if($this->Usage == 'Production' || $this->Usage == 'UAT') {
1163 1163
             $conflicting = DNEnvironment::get()
1164 1164
                 ->filter('ProjectID', $this->ProjectID)
1165 1165
                 ->filter('Usage', $this->Usage)
1166 1166
                 ->exclude('ID', $this->ID);
1167 1167
 
1168
-            foreach ($conflicting as $otherEnvironment) {
1168
+            foreach($conflicting as $otherEnvironment) {
1169 1169
                 $otherEnvironment->Usage = 'Unspecified';
1170 1170
                 $otherEnvironment->write();
1171 1171
             }
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
     {
1181 1181
         // Create folder if it doesn't exist
1182 1182
         $configDir = dirname($this->getConfigFilename());
1183
-        if (!file_exists($configDir) && $configDir) {
1183
+        if(!file_exists($configDir) && $configDir) {
1184 1184
             mkdir($configDir, 0777, true);
1185 1185
         }
1186 1186
     }
@@ -1190,18 +1190,18 @@  discard block
 block discarded – undo
1190 1190
      */
1191 1191
     protected function writeConfigFile()
1192 1192
     {
1193
-        if (!$this->config()->get('allow_web_editing')) {
1193
+        if(!$this->config()->get('allow_web_editing')) {
1194 1194
             return;
1195 1195
         }
1196 1196
 
1197 1197
         // Create a basic new environment config from a template
1198
-        if (!$this->envFileExists()
1198
+        if(!$this->envFileExists()
1199 1199
             && $this->Filename
1200 1200
             && $this->CreateEnvConfig
1201 1201
         ) {
1202 1202
             $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template';
1203 1203
             file_put_contents($this->getConfigFilename(), file_get_contents($templateFile));
1204
-        } elseif ($this->envFileExists() && $this->DeployConfig) {
1204
+        } elseif($this->envFileExists() && $this->DeployConfig) {
1205 1205
             file_put_contents($this->getConfigFilename(), $this->DeployConfig);
1206 1206
         }
1207 1207
     }
@@ -1211,14 +1211,14 @@  discard block
 block discarded – undo
1211 1211
      */
1212 1212
     protected function writePipelineFile()
1213 1213
     {
1214
-        if (!$this->config()->get('allow_web_editing')) {
1214
+        if(!$this->config()->get('allow_web_editing')) {
1215 1215
             return;
1216 1216
         }
1217 1217
         $path = $this->getPipelineFilename();
1218
-        if ($this->PipelineConfig) {
1218
+        if($this->PipelineConfig) {
1219 1219
             // Update file
1220 1220
             file_put_contents($path, $this->PipelineConfig);
1221
-        } elseif ($this->isChanged('PipelineConfig') && file_exists($path)) {
1221
+        } elseif($this->isChanged('PipelineConfig') && file_exists($path)) {
1222 1222
             // Remove file if deleted
1223 1223
             unlink($path);
1224 1224
         }
@@ -1231,12 +1231,12 @@  discard block
 block discarded – undo
1231 1231
     {
1232 1232
         parent::onAfterDelete();
1233 1233
         // Create a basic new environment config from a template
1234
-        if ($this->config()->get('allow_web_editing') && $this->envFileExists()) {
1234
+        if($this->config()->get('allow_web_editing') && $this->envFileExists()) {
1235 1235
             unlink($this->getConfigFilename());
1236 1236
         }
1237 1237
 
1238 1238
         $create = $this->CreateEnvironment();
1239
-        if ($create && $create->exists()) {
1239
+        if($create && $create->exists()) {
1240 1240
             $create->delete();
1241 1241
         }
1242 1242
     }
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
      */
1247 1247
     protected function getEnvironmentConfig()
1248 1248
     {
1249
-        if (!$this->envFileExists()) {
1249
+        if(!$this->envFileExists()) {
1250 1250
             return '';
1251 1251
         }
1252 1252
         return file_get_contents($this->getConfigFilename());
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
      */
1258 1258
     protected function envFileExists()
1259 1259
     {
1260
-        if (!$this->getConfigFilename()) {
1260
+        if(!$this->getConfigFilename()) {
1261 1261
             return false;
1262 1262
         }
1263 1263
         return file_exists($this->getConfigFilename());
@@ -1270,10 +1270,10 @@  discard block
 block discarded – undo
1270 1270
      */
1271 1271
     public function getConfigFilename()
1272 1272
     {
1273
-        if (!$this->Project()->exists()) {
1273
+        if(!$this->Project()->exists()) {
1274 1274
             return '';
1275 1275
         }
1276
-        if (!$this->Filename) {
1276
+        if(!$this->Filename) {
1277 1277
             return '';
1278 1278
         }
1279 1279
         return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename;
@@ -1288,11 +1288,11 @@  discard block
 block discarded – undo
1288 1288
     public function getPipelineFilename()
1289 1289
     {
1290 1290
         $name = $this->getConfigFilename();
1291
-        if (!$name) {
1291
+        if(!$name) {
1292 1292
             return null;
1293 1293
         }
1294 1294
         $path = pathinfo($name);
1295
-        if ($path) {
1295
+        if($path) {
1296 1296
             return $path['dirname'] . '/' . $path['filename'] . '.yml';
1297 1297
         }
1298 1298
     }
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
     protected function pipelineFileExists()
1306 1306
     {
1307 1307
         $filename = $this->getPipelineFilename();
1308
-        if (empty($filename)) {
1308
+        if(empty($filename)) {
1309 1309
             return false;
1310 1310
         }
1311 1311
         return file_exists($filename);
@@ -1322,24 +1322,24 @@  discard block
 block discarded – undo
1322 1322
     public static function array_to_viewabledata($array)
1323 1323
     {
1324 1324
         // Don't transform non-arrays
1325
-        if (!is_array($array)) {
1325
+        if(!is_array($array)) {
1326 1326
             return $array;
1327 1327
         }
1328 1328
 
1329 1329
         // Figure out whether this is indexed or associative
1330 1330
         $keys = array_keys($array);
1331 1331
         $assoc = ($keys != array_keys($keys));
1332
-        if ($assoc) {
1332
+        if($assoc) {
1333 1333
             // Treat as viewable data
1334 1334
             $data = new ArrayData(array());
1335
-            foreach ($array as $key => $value) {
1335
+            foreach($array as $key => $value) {
1336 1336
                 $data->setField($key, self::array_to_viewabledata($value));
1337 1337
             }
1338 1338
             return $data;
1339 1339
         } else {
1340 1340
             // Treat this as basic non-associative list
1341 1341
             $list = new ArrayList();
1342
-            foreach ($array as $value) {
1342
+            foreach($array as $value) {
1343 1343
                 $list->push(self::array_to_viewabledata($value));
1344 1344
             }
1345 1345
             return $list;
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
     {
1359 1359
         // check if this environment depends on another environemnt
1360 1360
         $dependsOnEnv = $this->DependsOnEnvironment();
1361
-        if (empty($dependsOnEnv)) {
1361
+        if(empty($dependsOnEnv)) {
1362 1362
             return null;
1363 1363
         }
1364 1364
 
@@ -1367,12 +1367,12 @@  discard block
 block discarded – undo
1367 1367
         $filter = isset($config->PipelineConfig->FilteredCommits)
1368 1368
             ? $config->PipelineConfig->FilteredCommits
1369 1369
             : null;
1370
-        if (empty($filter)) {
1370
+        if(empty($filter)) {
1371 1371
             return null;
1372 1372
         }
1373 1373
 
1374 1374
         // Create and execute filter
1375
-        if (!class_exists($filter)) {
1375
+        if(!class_exists($filter)) {
1376 1376
             throw new Exception(sprintf("Class %s does not exist", $filter));
1377 1377
         }
1378 1378
         $commitClass = $filter::create();
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
         $result = parent::validate();
1409 1409
         $backend = $this->Backend();
1410 1410
 
1411
-        if (strcasecmp('test', $this->Name) === 0 && get_class($backend) == 'CapistranoDeploymentBackend') {
1411
+        if(strcasecmp('test', $this->Name) === 0 && get_class($backend) == 'CapistranoDeploymentBackend') {
1412 1412
             $result->error('"test" is not a valid environment name when using Capistrano backend.');
1413 1413
         }
1414 1414
 
Please login to merge, or discard this patch.
code/model/DNFilteredCommits.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     public function getCommits()
48 48
     {
49
-        if (!isset($this->env)) {
49
+        if(!isset($this->env)) {
50 50
             $this->environmentNotSetException();
51 51
         }
52 52
         $successfulCommits =
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function getLatestCommit()
60 60
     {
61
-        if (!isset($this->env)) {
61
+        if(!isset($this->env)) {
62 62
             $this->environmentNotSetException();
63 63
         }
64 64
         $commits = $this->getCommits();
Please login to merge, or discard this patch.
code/model/DNProject.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
         // add the administrators group as the viewers of the new project
113 113
         $adminGroup = Group::get()->filter('Code', 'administrators')->first();
114
-        if ($adminGroup && $adminGroup->exists()) {
114
+        if($adminGroup && $adminGroup->exists()) {
115 115
             $project->Viewers()->add($adminGroup);
116 116
         }
117 117
         return $project;
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $size = 0;
129 129
 
130
-        foreach ($this->Environments() as $environment) {
131
-            foreach ($environment->DataArchives()->filter('IsBackup', 0) as $archive) {
130
+        foreach($this->Environments() as $environment) {
131
+            foreach($environment->DataArchives()->filter('IsBackup', 0) as $archive) {
132 132
                 $size += $archive->ArchiveFile()->getAbsoluteSize();
133 133
             }
134 134
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $size = $this->getField('DiskQuotaMB');
150 150
 
151
-        if (empty($size)) {
151
+        if(empty($size)) {
152 152
             $defaults = $this->config()->get('defaults');
153 153
             $size = (isset($defaults['DiskQuotaMB'])) ? $defaults['DiskQuotaMB'] : 0;
154 154
         }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     public function DiskQuotaUsagePercent()
185 185
     {
186 186
         $quota = $this->getDiskQuotaMB();
187
-        if ($quota > 0) {
187
+        if($quota > 0) {
188 188
             return $this->getUsedQuotaMB() * 100 / $quota;
189 189
         }
190 190
         return 100;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $controller = Controller::curr();
203 203
         $actionType = $controller->getField('CurrentActionType');
204 204
 
205
-        if (DNRoot::FlagSnapshotsEnabled() && $this->isProjectReady()) {
205
+        if(DNRoot::FlagSnapshotsEnabled() && $this->isProjectReady()) {
206 206
             $list->push(new ArrayData(array(
207 207
                 'Link' => sprintf('naut/project/%s/snapshots', $this->Name),
208 208
                 'Title' => 'Snapshots',
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function canView($member = null)
259 259
     {
260
-        if (!$member) {
260
+        if(!$member) {
261 261
             $member = Member::currentUser();
262 262
         }
263 263
 
264
-        if (Permission::checkMember($member, 'ADMIN')) {
264
+        if(Permission::checkMember($member, 'ADMIN')) {
265 265
             return true;
266 266
         }
267 267
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function canRestore($member = null)
277 277
     {
278
-        if ($this->allowedAny(
278
+        if($this->allowedAny(
279 279
             array(
280 280
                 DNRoot::ALLOW_PROD_SNAPSHOT,
281 281
                 DNRoot::ALLOW_NON_PROD_SNAPSHOT
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             return true;
286 286
         }
287 287
 
288
-        return (bool)$this->Environments()->filterByCallback(function ($env) use ($member) {
288
+        return (bool)$this->Environments()->filterByCallback(function($env) use ($member) {
289 289
             return $env->canRestore($member);
290 290
         })->Count();
291 291
     }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function canBackup($member = null)
298 298
     {
299
-        if ($this->allowedAny(
299
+        if($this->allowedAny(
300 300
             array(
301 301
                 DNRoot::ALLOW_PROD_SNAPSHOT,
302 302
                 DNRoot::ALLOW_NON_PROD_SNAPSHOT
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             return true;
307 307
         }
308 308
 
309
-        return (bool)$this->Environments()->filterByCallback(function ($env) use ($member) {
309
+        return (bool)$this->Environments()->filterByCallback(function($env) use ($member) {
310 310
             return $env->canBackup($member);
311 311
         })->Count();
312 312
     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
      */
318 318
     public function canUploadArchive($member = null)
319 319
     {
320
-        if ($this->allowedAny(
320
+        if($this->allowedAny(
321 321
             array(
322 322
                 DNRoot::ALLOW_PROD_SNAPSHOT,
323 323
                 DNRoot::ALLOW_NON_PROD_SNAPSHOT
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             return true;
328 328
         }
329 329
 
330
-        return (bool)$this->Environments()->filterByCallback(function ($env) use ($member) {
330
+        return (bool)$this->Environments()->filterByCallback(function($env) use ($member) {
331 331
             return $env->canUploadArchive($member);
332 332
         })->Count();
333 333
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
      */
339 339
     public function canDownloadArchive($member = null)
340 340
     {
341
-        if ($this->allowedAny(
341
+        if($this->allowedAny(
342 342
             array(
343 343
                 DNRoot::ALLOW_PROD_SNAPSHOT,
344 344
                 DNRoot::ALLOW_NON_PROD_SNAPSHOT
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
             return true;
349 349
         }
350 350
 
351
-        return (bool)$this->Environments()->filterByCallback(function ($env) use ($member) {
351
+        return (bool)$this->Environments()->filterByCallback(function($env) use ($member) {
352 352
             return $env->canDownloadArchive($member);
353 353
         })->Count();
354 354
     }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
     public function canCreateEnvironments($member = null)
367 367
     {
368 368
         $envType = $this->AllowedEnvironmentType;
369
-        if ($envType) {
369
+        if($envType) {
370 370
             $env = Injector::inst()->get($envType);
371
-            if ($env instanceof EnvironmentCreateBackend) {
371
+            if($env instanceof EnvironmentCreateBackend) {
372 372
                 return $this->allowed(DNRoot::ALLOW_CREATE_ENVIRONMENT, $member);
373 373
             }
374 374
         }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      */
408 408
     public function getProcessEnv()
409 409
     {
410
-        if (file_exists($this->getPrivateKeyPath())) {
410
+        if(file_exists($this->getPrivateKeyPath())) {
411 411
             // Key-pair is available, use it.
412 412
             $processEnv = array(
413 413
                 'IDENT_KEY' => $this->getPrivateKeyPath(),
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      */
457 457
     public function DNBranchList()
458 458
     {
459
-        if ($this->CVSPath && !$this->repoExists()) {
459
+        if($this->CVSPath && !$this->repoExists()) {
460 460
             $this->cloneRepo();
461 461
         }
462 462
         return DNBranchList::create($this, $this->DNData());
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      */
470 470
     public function DNTagList()
471 471
     {
472
-        if ($this->CVSPath && !$this->repoExists()) {
472
+        if($this->CVSPath && !$this->repoExists()) {
473 473
             $this->cloneRepo();
474 474
         }
475 475
         return DNReferenceList::create($this, $this->DNData(), null, null, true);
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public function getRepository()
482 482
     {
483
-        if (!$this->repoExists()) {
483
+        if(!$this->repoExists()) {
484 484
             return false;
485 485
         }
486 486
 
@@ -495,17 +495,17 @@  discard block
 block discarded – undo
495 495
      */
496 496
     public function DNEnvironmentList()
497 497
     {
498
-        if (!self::$_current_member_cache) {
498
+        if(!self::$_current_member_cache) {
499 499
             self::$_current_member_cache = Member::currentUser();
500 500
         }
501 501
 
502
-        if (self::$_current_member_cache === false) {
502
+        if(self::$_current_member_cache === false) {
503 503
             return new ArrayList();
504 504
         }
505 505
 
506 506
         $currentMember = self::$_current_member_cache;
507 507
         return $this->Environments()
508
-            ->filterByCallBack(function ($item) use ($currentMember) {
508
+            ->filterByCallBack(function($item) use ($currentMember) {
509 509
                 return $item->canView($currentMember);
510 510
             });
511 511
     }
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
      */
527 527
     public function currentBuilds()
528 528
     {
529
-        if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) {
529
+        if(!isset(self::$relation_cache['currentBuilds.' . $this->ID])) {
530 530
             $currentBuilds = array();
531
-            foreach ($this->Environments() as $env) {
531
+            foreach($this->Environments() as $env) {
532 532
                 $currentBuilds[$env->Name] = $env->CurrentBuild();
533 533
             }
534
-            self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds;
534
+            self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds;
535 535
         }
536
-        return self::$relation_cache['currentBuilds.'.$this->ID];
536
+        return self::$relation_cache['currentBuilds.' . $this->ID];
537 537
     }
538 538
 
539 539
     /**
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
      */
551 551
     public function CreateEnvironmentLink()
552 552
     {
553
-        if ($this->canCreateEnvironments()) {
553
+        if($this->canCreateEnvironments()) {
554 554
             return $this->Link('createenv');
555 555
         }
556 556
         return null;
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
     public function IsStarred()
571 571
     {
572 572
         $member = Member::currentUser();
573
-        if ($member === null) {
573
+        if($member === null) {
574 574
             return false;
575 575
         }
576 576
         $favourited = $this->StarredBy()->filter('MemberID', $member->ID);
577
-        if ($favourited->count() == 0) {
577
+        if($favourited->count() == 0) {
578 578
             return false;
579 579
         }
580 580
         return true;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 
632 632
         $environmentTypes = ClassInfo::implementorsOf('EnvironmentCreateBackend');
633 633
         $types = array();
634
-        foreach ($environmentTypes as $type) {
634
+        foreach($environmentTypes as $type) {
635 635
             $types[$type] = $type;
636 636
         }
637 637
 
@@ -656,11 +656,11 @@  discard block
 block discarded – undo
656 656
     public function setCreateProjectFolderField(&$fields)
657 657
     {
658 658
         // Check if the capistrano project folder exists
659
-        if (!$this->Name) {
659
+        if(!$this->Name) {
660 660
             return;
661 661
         }
662 662
 
663
-        if ($this->projectFolderExists()) {
663
+        if($this->projectFolderExists()) {
664 664
             return;
665 665
         }
666 666
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
     public function cloneRepo()
696 696
     {
697 697
         // Avoid this being called multiple times in the same request
698
-        if (!isset(self::$has_cloned_cache[$this->ID])) {
698
+        if(!isset(self::$has_cloned_cache[$this->ID])) {
699 699
             $fetch = DNGitFetch::create();
700 700
             $fetch->ProjectID = $this->ID;
701 701
             $fetch->write();
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
     {
722 722
         parent::onBeforeWrite();
723 723
 
724
-        if ($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) {
724
+        if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) {
725 725
             mkdir($this->getProjectFolderPath());
726 726
         }
727 727
     }
@@ -730,12 +730,12 @@  discard block
 block discarded – undo
730 730
     {
731 731
         parent::onAfterWrite();
732 732
 
733
-        if (!$this->CVSPath) {
733
+        if(!$this->CVSPath) {
734 734
             return;
735 735
         }
736 736
 
737 737
         $changedFields = $this->getChangedFields(true, 2);
738
-        if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) {
738
+        if(isset($changedFields['CVSPath']) || isset($changedFields['Name'])) {
739 739
             $this->cloneRepo();
740 740
         }
741 741
     }
@@ -748,22 +748,22 @@  discard block
 block discarded – undo
748 748
         parent::onAfterDelete();
749 749
 
750 750
         // Delete related environments
751
-        foreach ($this->Environments() as $env) {
751
+        foreach($this->Environments() as $env) {
752 752
             $env->delete();
753 753
         }
754 754
 
755 755
         // Delete local repository
756
-        if (file_exists($this->getLocalCVSPath())) {
756
+        if(file_exists($this->getLocalCVSPath())) {
757 757
             Filesystem::removeFolder($this->getLocalCVSPath());
758 758
         }
759 759
 
760 760
         // Delete project template
761
-        if (file_exists($this->getProjectFolderPath()) && Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
761
+        if(file_exists($this->getProjectFolderPath()) && Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
762 762
             Filesystem::removeFolder($this->getProjectFolderPath());
763 763
         }
764 764
 
765 765
         // Delete the deploy key
766
-        if (file_exists($this->getKeyDir())) {
766
+        if(file_exists($this->getKeyDir())) {
767 767
             Filesystem::removeFolder($this->getKeyDir());
768 768
         }
769 769
     }
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
     {
778 778
         $key = $this->getPublicKeyPath();
779 779
 
780
-        if (file_exists($key)) {
780
+        if(file_exists($key)) {
781 781
             return trim(file_get_contents($key));
782 782
         }
783 783
     }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
      */
790 790
     public function getPublicKeyPath()
791 791
     {
792
-        if ($privateKey = $this->getPrivateKeyPath()) {
792
+        if($privateKey = $this->getPrivateKeyPath()) {
793 793
             return $privateKey . '.pub';
794 794
         }
795 795
         return null;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     public function getPrivateKeyPath()
804 804
     {
805 805
         $keyDir = $this->getKeyDir();
806
-        if (!empty($keyDir)) {
806
+        if(!empty($keyDir)) {
807 807
             $filter = FileNameFilter::create();
808 808
             $name = $filter->filter($this->Name);
809 809
             return $keyDir . '/' . $name;
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     public function getKeyDir()
820 820
     {
821 821
         $keyDir = $this->DNData()->getKeyDir();
822
-        if (!$keyDir) {
822
+        if(!$keyDir) {
823 823
             return null;
824 824
         }
825 825
 
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
      */
838 838
     protected function setEnvironmentFields(&$fields, $environments)
839 839
     {
840
-        if (!$environments) {
840
+        if(!$environments) {
841 841
             return;
842 842
         }
843 843
 
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
         $environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
847 847
         $environments->getConfig()->removeComponentsByType('GridFieldDeleteAction');
848 848
         $environments->getConfig()->removeComponentsByType('GridFieldPageCount');
849
-        if (Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
849
+        if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
850 850
             $addNewRelease = new GridFieldAddNewButton('toolbar-header-right');
851 851
             $addNewRelease->setButtonName('Add');
852 852
             $environments->getConfig()->addComponent($addNewRelease);
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
     public function getRepositoryURL()
864 864
     {
865 865
         $showUrl = Config::inst()->get($this->class, 'show_repository_url');
866
-        if ($showUrl) {
866
+        if($showUrl) {
867 867
             return $this->CVSPath;
868 868
         }
869 869
     }
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
         $interfaces = $this->config()->repository_interfaces;
917 917
 
918 918
         /* Look for each whitelisted hostname */
919
-        foreach ($interfaces as $host => $interface) {
919
+        foreach($interfaces as $host => $interface) {
920 920
             /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */
921
-            if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
921
+            if(preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
922 922
                 $path = $match[2];
923 923
 
924 924
                 $scheme = isset($interface['scheme']) ? $interface['scheme'] : 'https';
@@ -927,13 +927,13 @@  discard block
 block discarded – undo
927 927
 
928 928
                 $components = explode('.', $host);
929 929
 
930
-                foreach ($regex as $pattern => $replacement) {
930
+                foreach($regex as $pattern => $replacement) {
931 931
                     $path = preg_replace('/' . $pattern . '/', $replacement, $path);
932 932
                 }
933 933
 
934 934
                 $uxurl = Controller::join_links($scheme . '://', $host, $path);
935 935
 
936
-                if (array_key_exists('commit', $interface) && $interface['commit'] == false) {
936
+                if(array_key_exists('commit', $interface) && $interface['commit'] == false) {
937 937
                     $commiturl = false;
938 938
                 } else {
939 939
                     $commiturl = Controller::join_links(
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
      */
981 981
     public function whoIsAllowedAny($codes)
982 982
     {
983
-        if (!is_array($codes)) {
983
+        if(!is_array($codes)) {
984 984
             $codes = array($codes);
985 985
         }
986 986
 
@@ -1023,11 +1023,11 @@  discard block
 block discarded – undo
1023 1023
     public function groupAllowed($permissionCode, Group $group)
1024 1024
     {
1025 1025
         $viewers = $this->Viewers();
1026
-        if (!$viewers->find('ID', $group->ID)) {
1026
+        if(!$viewers->find('ID', $group->ID)) {
1027 1027
             return false;
1028 1028
         }
1029 1029
         $groups = Permission::get_groups_by_permission($permissionCode);
1030
-        if (!$groups->find('ID', $group->ID)) {
1030
+        if(!$groups->find('ID', $group->ID)) {
1031 1031
             return false;
1032 1032
         }
1033 1033
         return true;
@@ -1043,16 +1043,16 @@  discard block
 block discarded – undo
1043 1043
      */
1044 1044
     public function allowedAny($codes, $member = null)
1045 1045
     {
1046
-        if (!$member) {
1046
+        if(!$member) {
1047 1047
             $member = Member::currentUser();
1048 1048
         }
1049 1049
 
1050
-        if (Permission::checkMember($member, 'ADMIN')) {
1050
+        if(Permission::checkMember($member, 'ADMIN')) {
1051 1051
             return true;
1052 1052
         }
1053 1053
 
1054 1054
         $hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count();
1055
-        return ($hits>0 ? true : false);
1055
+        return ($hits > 0 ? true : false);
1056 1056
     }
1057 1057
 
1058 1058
     /**
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
      */
1063 1063
     public function isProjectReady()
1064 1064
     {
1065
-        if ($this->getRunningInitialEnvironmentCreations()->count() > 0) {
1065
+        if($this->getRunningInitialEnvironmentCreations()->count() > 0) {
1066 1066
             // We're still creating the initial environments for this project so we're
1067 1067
             // not quite done
1068 1068
             return false;
@@ -1071,13 +1071,13 @@  discard block
 block discarded – undo
1071 1071
         // Provide a hook for further checks. Logic stolen from
1072 1072
         // {@see DataObject::extendedCan()}
1073 1073
         $isDone = $this->extend('isProjectReady');
1074
-        if ($isDone && is_array($isDone)) {
1075
-            $isDone = array_filter($isDone, function ($val) {
1074
+        if($isDone && is_array($isDone)) {
1075
+            $isDone = array_filter($isDone, function($val) {
1076 1076
                 return !is_null($val);
1077 1077
             });
1078 1078
 
1079 1079
             // If anything returns false then we're not ready.
1080
-            if ($isDone) {
1080
+            if($isDone) {
1081 1081
                 return min($isDone);
1082 1082
             }
1083 1083
         }
@@ -1134,25 +1134,25 @@  discard block
 block discarded – undo
1134 1134
     protected function validate()
1135 1135
     {
1136 1136
         $validation = parent::validate();
1137
-        if ($validation->valid()) {
1138
-            if (empty($this->Name)) {
1137
+        if($validation->valid()) {
1138
+            if(empty($this->Name)) {
1139 1139
                 return $validation->error('The stack must have a name.');
1140 1140
             }
1141 1141
 
1142 1142
             // The name is used to build filepaths so should be restricted
1143
-            if (!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+$/', $this->Name)) {
1143
+            if(!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+$/', $this->Name)) {
1144 1144
                 return $validation->error('Project name can only contain alphanumeric, hyphens and underscores.');
1145 1145
             }
1146 1146
 
1147
-            if (empty($this->CVSPath)) {
1147
+            if(empty($this->CVSPath)) {
1148 1148
                 return $validation->error('You must provide a repository URL.');
1149 1149
             }
1150 1150
 
1151 1151
             $existing = DNProject::get()->filter('Name', $this->Name);
1152
-            if ($this->ID) {
1152
+            if($this->ID) {
1153 1153
                 $existing = $existing->exclude('ID', $this->ID);
1154 1154
             }
1155
-            if ($existing->count() > 0) {
1155
+            if($existing->count() > 0) {
1156 1156
                 return $validation->error('A stack already exists with that name.');
1157 1157
             }
1158 1158
         }
@@ -1166,14 +1166,14 @@  discard block
 block discarded – undo
1166 1166
      */
1167 1167
     public function canCreate($member = null)
1168 1168
     {
1169
-        if (!$member) {
1169
+        if(!$member) {
1170 1170
             $member = Member::currentUser();
1171 1171
         }
1172
-        if (!$member) {
1172
+        if(!$member) {
1173 1173
             return false;
1174 1174
         }
1175 1175
 
1176
-        if (Permission::checkMember($member, 'ADMIN')) {
1176
+        if(Permission::checkMember($member, 'ADMIN')) {
1177 1177
             return true;
1178 1178
         }
1179 1179
 
Please login to merge, or discard this patch.
code/model/DNReferenceList.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
     {
106 106
         try {
107 107
             $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
108
-        } catch (Exception $e) {
108
+        } catch(Exception $e) {
109 109
             return array();
110 110
         }
111 111
 
112
-        if ($this->getTags) {
113
-            if ($this->reference) {
112
+        if($this->getTags) {
113
+            if($this->reference) {
114 114
                 throw new LogicException("Can't have \$reference and \$getTags both set");
115 115
             }
116 116
             $log = $repository->getReferences()->getTags();
117
-        } elseif ($this->reference) {
117
+        } elseif($this->reference) {
118 118
             $log = $this->reference->getLog();
119 119
         } else {
120 120
             $log = $repository->getLog();
121 121
         }
122 122
 
123
-        if ($this->limit) {
124
-            if (is_array($log)) {
123
+        if($this->limit) {
124
+            if(is_array($log)) {
125 125
                 $limitedLog = array_slice($log, 0, $this->limit);
126 126
             } else {
127 127
                 $limitedLog = $log->setLimit($this->limit);
@@ -132,18 +132,18 @@  discard block
 block discarded – undo
132 132
 
133 133
         // cache them for look up in byName
134 134
         $builds = array();
135
-        foreach ($limitedLog as $reference) {
136
-            if (!empty($this->blockBranch)) {
135
+        foreach($limitedLog as $reference) {
136
+            if(!empty($this->blockBranch)) {
137 137
                 $branchesIncluding = GitonomyCache::getIncludingBranches($reference);
138
-                foreach ($branchesIncluding as $candidate) {
139
-                    if ($candidate->getName() == $this->blockBranch) {
138
+                foreach($branchesIncluding as $candidate) {
139
+                    if($candidate->getName() == $this->blockBranch) {
140 140
                         // Break out of the function
141 141
                         return $builds;
142 142
                     }
143 143
                 }
144 144
             }
145 145
 
146
-            if ($this->getTags) {
146
+            if($this->getTags) {
147 147
                 $builds[] = DNTag::create($reference, $this->project, $this->data);
148 148
             } else {
149 149
                 $name = $this->reference ? $this->reference->getName() : '';
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function byName($hash)
164 164
     {
165
-        if ($this->loaded === false) {
165
+        if($this->loaded === false) {
166 166
             $this->items = $this->getReferences();
167 167
             $this->loaded = true;
168 168
         }
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
         // The item might not be in the list because of the limit, try to find
171 171
         // in an older version and add it to the list.
172 172
         $found = null;
173
-        foreach ($this->items as $item) {
174
-            if ($item->SHA() == $hash) {
173
+        foreach($this->items as $item) {
174
+            if($item->SHA() == $hash) {
175 175
                 $found = $item;
176 176
                 break;
177 177
             }
178 178
         }
179 179
 
180
-        if ($found === null) {
180
+        if($found === null) {
181 181
             $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
182 182
             $commit = new Gitonomy\Git\Commit($repository, $hash);
183 183
             $found = DNCommit::create($commit, $this->project, $this->data);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function getIterator()
202 202
     {
203
-        if ($this->loaded === false) {
203
+        if($this->loaded === false) {
204 204
             $this->items = $this->getReferences();
205 205
             $this->loaded = true;
206 206
         }
207
-        foreach ($this->items as $item) {
208
-            if (is_array($item)) {
207
+        foreach($this->items as $item) {
208
+            if(is_array($item)) {
209 209
                 $this->items[] = new ArrayData($item);
210 210
             }
211 211
         }
Please login to merge, or discard this patch.
code/model/GitonomyCache.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     public static function getIncludingBranches($commit)
11 11
     {
12 12
         $cacheKey = 'getIncludingBranches-' . $commit->getRepository()->getPath() . '-' . $commit->gethash();
13
-        if (!isset(self::$cache[$cacheKey])) {
13
+        if(!isset(self::$cache[$cacheKey])) {
14 14
             self::$cache[$cacheKey] = $commit->getIncludingBranches();
15 15
         }
16 16
         return self::$cache[$cacheKey];
Please login to merge, or discard this patch.
code/model/Pipeline.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     {
230 230
         // Workaround fixed in https://github.com/silverstripe/silverstripe-framework/pull/3201
231 231
         // Remove this once we update to a version of framework which supports this
232
-        if ($property === 'MessagingService') {
232
+        if($property === 'MessagingService') {
233 233
             return !empty($this->messagingService);
234 234
         }
235 235
         return parent::__isset($property);
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
     {
274 274
         // Owner can abort
275 275
         $member = $member ?: Member::currentUser();
276
-        if (!$member) {
276
+        if(!$member) {
277 277
             return false;
278 278
         }
279
-        if ($member->ID == $this->AuthorID) {
279
+        if($member->ID == $this->AuthorID) {
280 280
             return true;
281 281
         }
282 282
 
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function getRunningDescription()
293 293
     {
294
-        if (!$this->isActive()) {
294
+        if(!$this->isActive()) {
295 295
             return 'This pipeline is not currently running';
296 296
         }
297 297
         $result = '';
298
-        if ($step = $this->CurrentStep()) {
298
+        if($step = $this->CurrentStep()) {
299 299
             $result = $step->getRunningDescription();
300 300
         }
301 301
         return $result ?: 'This pipeline is currently running';
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
      */
309 309
     public function RunningOptions()
310 310
     {
311
-        if (!$this->isActive()) {
311
+        if(!$this->isActive()) {
312 312
             return null;
313 313
         }
314 314
         $actions = array();
315 315
 
316 316
         // Let current step update the current list of options
317
-        if (($step = $this->CurrentStep()) && ($step->isRunning())) {
317
+        if(($step = $this->CurrentStep()) && ($step->isRunning())) {
318 318
             $actions = $step->allowedActions();
319 319
         }
320 320
         return new ArrayList($actions);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      */
328 328
     public function LogOptions()
329 329
     {
330
-        if (!$this->isActive()) {
330
+        if(!$this->isActive()) {
331 331
             return null;
332 332
         }
333 333
 
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
             'Link' => $this->Link()
339 339
         );
340 340
 
341
-        if ($this->PreviousSnapshotID > 0) {
341
+        if($this->PreviousSnapshotID > 0) {
342 342
             $logs[] = array(
343 343
                 'ButtonText' => 'Snapshot Log',
344 344
                 'Link' => $this->PreviousSnapshot()->Link()
345 345
             );
346 346
         }
347 347
 
348
-        if ($this->CurrentDeploymentID > 0) {
348
+        if($this->CurrentDeploymentID > 0) {
349 349
             $logs[] = array(
350 350
                 'ButtonText' => 'Deployment Log',
351 351
                 'Link' => $this->CurrentDeployment()->Link()
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
 
355 355
         // Get logs from rollback steps (only for RollbackSteps).
356 356
         $rollbackSteps = array($this->RollbackStep1(), $this->RollbackStep2());
357
-        foreach ($rollbackSteps as $rollback) {
358
-            if ($rollback->exists() && $rollback->ClassName == 'RollbackStep') {
359
-                if ($rollback->RollbackDeploymentID > 0) {
357
+        foreach($rollbackSteps as $rollback) {
358
+            if($rollback->exists() && $rollback->ClassName == 'RollbackStep') {
359
+                if($rollback->RollbackDeploymentID > 0) {
360 360
                     $logs[] = array(
361 361
                         'ButtonText' => 'Rollback Log',
362 362
                         'Link' => $rollback->RollbackDeployment()->Link()
363 363
                     );
364 364
                 }
365 365
 
366
-                if ($rollback->RollbackDatabaseID > 0) {
366
+                if($rollback->RollbackDatabaseID > 0) {
367 367
                     $logs[] = array(
368 368
                         'ButtonText' => 'Rollback DB Log',
369 369
                         'Link' => $rollback->RollbackDatabase()->Link()
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
     {
395 395
         // Lazy load if necessary
396 396
         $data = null;
397
-        if (!$this->Config && ($data = $this->Environment()->loadPipelineConfig())) {
397
+        if(!$this->Config && ($data = $this->Environment()->loadPipelineConfig())) {
398 398
             $this->Config = serialize($data);
399 399
         }
400 400
 
401 401
         // Merge with defaults
402
-        if ($this->Config) {
403
-            if (!$this->mergedConfig) {
402
+        if($this->Config) {
403
+            if(!$this->mergedConfig) {
404 404
                 $this->mergedConfig = $data ?: unserialize($this->Config);
405
-                if ($default = self::config()->default_config) {
405
+                if($default = self::config()->default_config) {
406 406
                     Config::merge_array_low_into_high($this->mergedConfig, $default);
407 407
                 }
408 408
             }
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
     {
431 431
         $source = $this->getConfigData();
432 432
 
433
-        foreach (func_get_args() as $setting) {
434
-            if (empty($source[$setting])) {
433
+        foreach(func_get_args() as $setting) {
434
+            if(empty($source[$setting])) {
435 435
                 return null;
436 436
             }
437 437
             $source = $source[$setting];
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 ->performReadonlyTransformation()
482 482
         ));
483 483
 
484
-        if ($log = $this->LogContent()) {
484
+        if($log = $this->LogContent()) {
485 485
             $fields->addFieldToTab(
486 486
                 'Root.Main',
487 487
                 ToggleCompositeField::create(
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
510 510
         // dependent environment not available
511 511
         $projectName = $this->getConfigSetting('PipelineConfig', 'DependsOnProject');
512 512
         $environmentName = $this->getConfigSetting('PipelineConfig', 'DependsOnEnvironment');
513
-        if (empty($projectName) || empty($environmentName)) {
513
+        if(empty($projectName) || empty($environmentName)) {
514 514
             return null;
515 515
         }
516 516
 
517 517
         $project = DNProject::get()->filter('Name', $projectName)->first();
518
-        if (!($project && $project->exists())) {
518
+        if(!($project && $project->exists())) {
519 519
             throw new Exception(sprintf('Could not find dependent project "%s"', $projectName));
520 520
         }
521 521
 
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             'Name' => $environmentName
525 525
         ))->first();
526 526
 
527
-        if (!($environment && $environment->exists())) {
527
+        if(!($environment && $environment->exists())) {
528 528
             throw new Exception(sprintf(
529 529
                 'Could not find dependent environment "%s" in project "%s"',
530 530
                 $environmentName,
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
     {
549 549
         $stepClass = isset($stepConfig['Class']) ? $stepConfig['Class'] : $stepConfig;
550 550
 
551
-        if (empty($stepClass)) {
551
+        if(empty($stepClass)) {
552 552
             throw new Exception(
553 553
                 sprintf('Missing or empty Class specifier for step "%s"', $name)
554 554
             );
555 555
         }
556 556
 
557
-        if (!is_subclass_of($stepClass, 'PipelineStep')) {
557
+        if(!is_subclass_of($stepClass, 'PipelineStep')) {
558 558
             throw new Exception(
559 559
                 sprintf('%s is not a valid "Class" field name for step "%s"', var_export($stepClass, true), $name)
560 560
             );
@@ -588,18 +588,18 @@  discard block
 block discarded – undo
588 588
         // Ensure there are no other running {@link Pipeline} objects for this {@link DNEnvironment}
589 589
         // Requires that $this->EnvironmentID has been set
590 590
         $env = $this->Environment();
591
-        if (!($env && $env->exists())) {
591
+        if(!($env && $env->exists())) {
592 592
             throw new LogicException("This pipeline needs a valid environment to run on.");
593 593
         }
594 594
 
595
-        if ($env->HasCurrentPipeline()) {
595
+        if($env->HasCurrentPipeline()) {
596 596
             throw new LogicException("You can only run one pipeline at a time on this environment.");
597 597
         }
598 598
 
599 599
         $this->write(); // ensure we've written this record first
600 600
 
601 601
         // Instantiate steps.
602
-        foreach ($this->getConfigSetting('Steps') as $name => $stepConfig) {
602
+        foreach($this->getConfigSetting('Steps') as $name => $stepConfig) {
603 603
             $this->pushPipelineStep($name, $stepConfig);
604 604
         }
605 605
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         $this->log("Pipeline completed successfully.");
621 621
         $this->write();
622 622
         // Some steps may pre-emptively send a success message before the pipeline itself has completed
623
-        if ($this->LastMessageSent !== self::ALERT_SUCCESS) {
623
+        if($this->LastMessageSent !== self::ALERT_SUCCESS) {
624 624
             $this->sendMessage(self::ALERT_SUCCESS);
625 625
         }
626 626
     }
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
         $success = true;
678 678
         $rollback1 = $this->RollbackStep1();
679 679
         $rollback2 = $this->RollbackStep2();
680
-        if (!empty($rollback1) && $rollback1->Status == 'Failed') {
680
+        if(!empty($rollback1) && $rollback1->Status == 'Failed') {
681 681
             $success = false;
682 682
         }
683
-        if (!empty($rollback2) && $rollback2->Status == 'Failed') {
683
+        if(!empty($rollback2) && $rollback2->Status == 'Failed') {
684 684
             $success = false;
685 685
         }
686 686
 
687 687
         // Send messages.
688
-        if ($success) {
688
+        if($success) {
689 689
             $this->log("Pipeline failed, but rollback completed successfully.");
690 690
             $this->sendMessage(self::ALERT_ROLLBACK_SUCCESS);
691 691
         } else {
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
         // Add smoke test step, if available, for later processing.
717 717
         $configRollback2 = $this->getConfigSetting('RollbackStep2');
718
-        if ($configRollback2) {
718
+        if($configRollback2) {
719 719
             $stepRollback2 = $this->pushPipelineStep('RollbackStep2', $configRollback2);
720 720
             $this->RollbackStep2ID = $stepRollback2->ID;
721 721
         }
@@ -734,24 +734,24 @@  discard block
 block discarded – undo
734 734
     protected function canStartRollback()
735 735
     {
736 736
         // The rollback cannot run twice.
737
-        if ($this->isRollback()) {
737
+        if($this->isRollback()) {
738 738
             return false;
739 739
         }
740 740
 
741 741
         // Rollbacks must be configured.
742
-        if (!$this->getConfigSetting('RollbackStep1')) {
742
+        if(!$this->getConfigSetting('RollbackStep1')) {
743 743
             return false;
744 744
         }
745 745
 
746 746
         // On dryrun let rollback run
747
-        if ($this->DryRun) {
747
+        if($this->DryRun) {
748 748
             return true;
749 749
         }
750 750
 
751 751
         // Pipeline must have ran a deployment to be able to rollback.
752 752
         $deploy = $this->CurrentDeployment();
753 753
         $previous = $this->PreviousDeployment();
754
-        if (!$deploy->exists() || !$previous->exists()) {
754
+        if(!$deploy->exists() || !$previous->exists()) {
755 755
             return false;
756 756
         }
757 757
 
@@ -769,22 +769,22 @@  discard block
 block discarded – undo
769 769
     {
770 770
         // Abort all running or queued steps.
771 771
         $steps = $this->Steps();
772
-        foreach ($steps as $step) {
773
-            if ($step->isQueued() || $step->isRunning()) {
772
+        foreach($steps as $step) {
773
+            if($step->isQueued() || $step->isRunning()) {
774 774
                 $step->abort();
775 775
             }
776 776
         }
777 777
 
778
-        if ($this->canStartRollback()) {
778
+        if($this->canStartRollback()) {
779 779
             $this->beginRollback();
780
-        } elseif ($this->isRollback()) {
780
+        } elseif($this->isRollback()) {
781 781
             $this->finaliseRollback();
782 782
         } else {
783 783
             // Not able to roll back - fail immediately.
784 784
             $this->Status = 'Failed';
785 785
             $this->log("Pipeline failed, not running rollback (not configured or not applicable yet).");
786 786
             $this->write();
787
-            if ($notify) {
787
+            if($notify) {
788 788
                 $this->sendMessage(self::ALERT_FAILURE);
789 789
             }
790 790
         }
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 
823 823
         // Abort all running or queued steps.
824 824
         $steps = $this->Steps();
825
-        foreach ($steps as $step) {
826
-            if ($step->isQueued() || $step->isRunning()) {
825
+        foreach($steps as $step) {
826
+            if($step->isQueued() || $step->isRunning()) {
827 827
                 $step->abort();
828 828
             }
829 829
         }
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     public function injectMessageReplacements($message, $subject, $substitutions)
858 858
     {
859 859
         // Handle empty messages
860
-        if (empty($subject) && empty($message)) {
860
+        if(empty($subject) && empty($message)) {
861 861
             return array(null, null);
862 862
         }
863 863
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
     {
888 888
         // Check message, subject, and additional arguments to include
889 889
         list($subject, $message) = $this->generateMessageTemplate($messageID);
890
-        if (empty($subject) || empty($message)) {
890
+        if(empty($subject) || empty($message)) {
891 891
             $this->log("Skipping sending message. None configured for $messageID");
892 892
             return true;
893 893
         }
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
         );
904 904
 
905 905
         // Send message to author
906
-        if ($author = $this->Author()) {
906
+        if($author = $this->Author()) {
907 907
             $this->log("Pipeline sending $messageID message to {$author->Email}");
908 908
             $this->messagingService->sendMessage($this, $message, $author, $arguments);
909 909
         } else {
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 
913 913
         // Get additional recipients
914 914
         $recipients = $this->getConfigSetting('PipelineConfig', 'Recipients', $messageID);
915
-        if (empty($recipients)) {
915
+        if(empty($recipients)) {
916 916
             $this->log("Skipping sending message to empty recipients");
917 917
         } else {
918 918
             $recipientsStr = is_array($recipients) ? implode(',', $recipients) : $recipients;
@@ -944,11 +944,11 @@  discard block
 block discarded – undo
944 944
     {
945 945
         $message = "";
946 946
 
947
-        if (!$this->isActive()) {
947
+        if(!$this->isActive()) {
948 948
             $message = "Pipeline::checkPipelineStatus() should only be called on running or rolling back pipelines.";
949 949
         }
950 950
 
951
-        if (!$this->ID || !$this->isInDB()) {
951
+        if(!$this->ID || !$this->isInDB()) {
952 952
             $message = "Pipeline::checkPipelineStatus() can only be called on pipelines already saved.";
953 953
         }
954 954
 
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
             ? $this->CurrentStep()
957 957
             : null;
958 958
 
959
-        if ($currentStep && $currentStep->PipelineID != $this->ID) {
959
+        if($currentStep && $currentStep->PipelineID != $this->ID) {
960 960
             $message = sprintf(
961 961
                 "The current step (#%d) has a pipeline ID (#%d) that doesn't match this pipeline's ID (#%d).",
962 962
                 $currentStep->ID,
@@ -965,13 +965,13 @@  discard block
 block discarded – undo
965 965
             );
966 966
         }
967 967
 
968
-        if ($message) {
968
+        if($message) {
969 969
             $this->log($message);
970 970
             throw new LogicException($message);
971 971
         }
972 972
 
973 973
         // Fallback check only: this shouldn't be called unless a {@link PipelineStep} has been implemented incorrectly
974
-        if ($currentStep && $currentStep->isFailed() && !$this->isFailed() && !$this->isRollback()) {
974
+        if($currentStep && $currentStep->isFailed() && !$this->isFailed() && !$this->isRollback()) {
975 975
             $this->log(sprintf("Marking pipeline step (#%d) as failed - this pipeline step needs to be amended to mark"
976 976
                 . " the pipeline (as well as itself) as failed to ensure consistency.",
977 977
                 $this->CurrentStep()->ID
@@ -983,22 +983,22 @@  discard block
 block discarded – undo
983 983
 
984 984
         // If this is the first time the Pipeline is run, then we don't have a CurrentStep, so set it,
985 985
         // start it running, and return
986
-        if (!$currentStep) {
986
+        if(!$currentStep) {
987 987
             $step = $this->Steps()->first();
988 988
             $this->CurrentStepID = $step->ID;
989 989
             $this->write();
990 990
 
991 991
             $this->log("Starting first pipeline step...");
992 992
             $step->start();
993
-        } elseif ($currentStep->isFinished()) {
993
+        } elseif($currentStep->isFinished()) {
994 994
             // Sort through the list of {@link PipelineStep} objects to find the next step we need to start.
995 995
             $this->log("Finding next step to execute...");
996 996
             $nextStep = $this->findNextStep();
997 997
 
998
-            if (!$nextStep) {
998
+            if(!$nextStep) {
999 999
 
1000 1000
                 // Special handling, since the main pipeline has already failed at this stage.
1001
-                if ($this->isRollback()) {
1001
+                if($this->isRollback()) {
1002 1002
                     $this->finaliseRollback();
1003 1003
                     return false;
1004 1004
                 }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
                     'PipelineID' => $this->ID,
1009 1009
                     'Status' => 'Failed'
1010 1010
                 ))->count();
1011
-                if ($failedSteps) {
1011
+                if($failedSteps) {
1012 1012
                     $this->log('At least one of the steps has failed marking the pipeline as failed');
1013 1013
                     $this->markFailed();
1014 1014
                     return false;
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                 $nextStep->start();
1026 1026
             }
1027 1027
         // if the current step is failing run it again
1028
-        } elseif ($step = $this->CurrentStep()) {
1028
+        } elseif($step = $this->CurrentStep()) {
1029 1029
             $step->start();
1030 1030
         }
1031 1031
     }
@@ -1093,11 +1093,11 @@  discard block
 block discarded – undo
1093 1093
         $caller['line'] = $bt[($index - 1)]['line']; // Overwrite line and file to be the the line/file that actually
1094 1094
         $caller['file'] = $bt[($index - 1)]['file']; // called the function, not where the function is defined.
1095 1095
         // In case it wasn't called from a class
1096
-        if (!isset($caller['class'])) {
1096
+        if(!isset($caller['class'])) {
1097 1097
             $caller['class'] = '';
1098 1098
         }
1099 1099
         // In case it doesn't have a type (wasn't called from class)
1100
-        if (!isset($caller['type'])) {
1100
+        if(!isset($caller['type'])) {
1101 1101
             $caller['type'] = '';
1102 1102
         }
1103 1103
 
@@ -1118,15 +1118,15 @@  discard block
 block discarded – undo
1118 1118
      */
1119 1119
     public function getLogger()
1120 1120
     {
1121
-        if (!$this->isInDB()) {
1121
+        if(!$this->isInDB()) {
1122 1122
             throw new RuntimeException("Can't write to a log file until we know the database ID.");
1123 1123
         }
1124 1124
 
1125
-        if (!$this->Environment()) {
1125
+        if(!$this->Environment()) {
1126 1126
             throw new RuntimeException("Can't write to a log file until we have an Environment.");
1127 1127
         }
1128 1128
 
1129
-        if ($this->Environment() && !$this->Environment()->Project()) {
1129
+        if($this->Environment() && !$this->Environment()->Project()) {
1130 1130
             throw new RuntimeException("Can't write to a log file until we have the Environment's project.");
1131 1131
         }
1132 1132
 
@@ -1186,9 +1186,9 @@  discard block
 block discarded – undo
1186 1186
      */
1187 1187
     public function LogContent()
1188 1188
     {
1189
-        if ($this->exists() && $this->Environment()) {
1189
+        if($this->exists() && $this->Environment()) {
1190 1190
             $logger = $this->getLogger();
1191
-            if ($logger->exists()) {
1191
+            if($logger->exists()) {
1192 1192
                 return $logger->content();
1193 1193
             }
1194 1194
         }
Please login to merge, or discard this patch.
code/model/jobs/DNCreateEnvironment.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
         $status = new Resque_Job_Status($this->ResqueToken);
121 121
         $statusCode = $status->get();
122 122
         // The Resque job can no longer be found, fallback to the DNDeployment.Status
123
-        if ($statusCode === false) {
123
+        if($statusCode === false) {
124 124
             // Translate from the DNDeployment.Status to the Resque job status for UI purposes
125
-            switch ($this->Status) {
125
+            switch($this->Status) {
126 126
                 case 'Finished':
127 127
                     return 'Complete';
128 128
                 case 'Started':
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
             'projectName' => $project->Name
151 151
         );
152 152
 
153
-        if (!$this->CreatorID) {
153
+        if(!$this->CreatorID) {
154 154
             $this->CreatorID = Member::currentUserID();
155 155
         }
156 156
 
157
-        if ($this->CreatorID) {
157
+        if($this->CreatorID) {
158 158
             $creator = $this->Creator();
159 159
             $message = sprintf(
160 160
                 'Environment creation for project %s initiated by %s (%s), with IP address %s',
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     public function createEnvironment()
185 185
     {
186 186
         $backend = $this->getBackend();
187
-        if ($backend) {
187
+        if($backend) {
188 188
             return $backend->createEnvironment($this);
189 189
         }
190 190
         throw new Exception("Unable to find backend.");
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
     public function getBackend()
200 200
     {
201 201
         $data = unserialize($this->Data);
202
-        if (isset($data['EnvironmentType']) && class_exists($data['EnvironmentType'])) {
202
+        if(isset($data['EnvironmentType']) && class_exists($data['EnvironmentType'])) {
203 203
             $env = Injector::inst()->get($data['EnvironmentType']);
204
-            if ($env instanceof EnvironmentCreateBackend) {
204
+            if($env instanceof EnvironmentCreateBackend) {
205 205
                 return $env;
206 206
             } else {
207 207
                 throw new Exception("Invalid backend: " . $data['EnvironmentType']);
Please login to merge, or discard this patch.