Completed
Pull Request — master (#657)
by Sean
06:18
created
code/model/DNProject.php 2 patches
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -929,7 +929,9 @@  discard block
 block discarded – undo
929 929
 	 * @return SS_List
930 930
 	 */
931 931
 	public function whoIsAllowedAny($codes) {
932
-		if(!is_array($codes)) $codes = array($codes);
932
+		if(!is_array($codes)) {
933
+			$codes = array($codes);
934
+		}
933 935
 
934 936
 		$SQLa_codes = Convert::raw2sql($codes);
935 937
 		$SQL_codes = join("','", $SQLa_codes);
@@ -991,7 +993,9 @@  discard block
 block discarded – undo
991 993
 			$member = Member::currentUser();
992 994
 		}
993 995
 
994
-		if(Permission::checkMember($member, 'ADMIN')) return true;
996
+		if(Permission::checkMember($member, 'ADMIN')) {
997
+			return true;
998
+		}
995 999
 
996 1000
 		$hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count();
997 1001
 		return ($hits>0 ? true : false);
@@ -1018,7 +1022,9 @@  discard block
 block discarded – undo
1018 1022
 			});
1019 1023
 
1020 1024
 			// If anything returns false then we're not ready.
1021
-			if($isDone) return min($isDone);
1025
+			if($isDone) {
1026
+				return min($isDone);
1027
+			}
1022 1028
 		}
1023 1029
 
1024 1030
 		return true;
@@ -1099,8 +1105,12 @@  discard block
 block discarded – undo
1099 1105
 	 * @return bool
1100 1106
 	 */
1101 1107
 	public function canCreate($member = null) {
1102
-		if(!$member) $member = Member::currentUser();
1103
-		if(!$member) return false;
1108
+		if(!$member) {
1109
+			$member = Member::currentUser();
1110
+		}
1111
+		if(!$member) {
1112
+			return false;
1113
+		}
1104 1114
 
1105 1115
 		if(Permission::checkMember($member, 'ADMIN')) {
1106 1116
 			return true;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 		// add the administrators group as the viewers of the new project
111 111
 		$adminGroup = Group::get()->filter('Code', 'administrators')->first();
112
-		if($adminGroup && $adminGroup->exists()) {
112
+		if ($adminGroup && $adminGroup->exists()) {
113 113
 			$project->Viewers()->add($adminGroup);
114 114
 		}
115 115
 		return $project;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	public function getUsedQuotaMB($round = 2) {
125 125
 		$size = 0;
126 126
 
127
-		foreach($this->Environments() as $environment) {
128
-			foreach($environment->DataArchives()->filter('IsBackup', 0) as $archive) {
127
+		foreach ($this->Environments() as $environment) {
128
+			foreach ($environment->DataArchives()->filter('IsBackup', 0) as $archive) {
129 129
 				$size += $archive->ArchiveFile()->getAbsoluteSize();
130 130
 			}
131 131
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	public function getDiskQuotaMB() {
145 145
 		$size = $this->getField('DiskQuotaMB');
146 146
 
147
-		if(empty($size)) {
147
+		if (empty($size)) {
148 148
 			$defaults = $this->config()->get('defaults');
149 149
 			$size = (isset($defaults['DiskQuotaMB'])) ? $defaults['DiskQuotaMB'] : 0;
150 150
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function DiskQuotaUsagePercent() {
179 179
 		$quota = $this->getDiskQuotaMB();
180
-		if($quota > 0) {
180
+		if ($quota > 0) {
181 181
 			return $this->getUsedQuotaMB() * 100 / $quota;
182 182
 		}
183 183
 		return 100;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$controller = Controller::curr();
195 195
 		$actionType = $controller->getField('CurrentActionType');
196 196
 
197
-		if(DNRoot::FlagSnapshotsEnabled() && $this->isProjectReady()) {
197
+		if (DNRoot::FlagSnapshotsEnabled() && $this->isProjectReady()) {
198 198
 			$list->push(new ArrayData(array(
199 199
 				'Link' => sprintf('naut/project/%s/snapshots', $this->Name),
200 200
 				'Title' => 'Snapshots',
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 * @return boolean
246 246
 	 */
247 247
 	public function canView($member = null) {
248
-		if(!$member) {
248
+		if (!$member) {
249 249
 			$member = Member::currentUser();
250 250
 		}
251 251
 
252
-		if(Permission::checkMember($member, 'ADMIN')) {
252
+		if (Permission::checkMember($member, 'ADMIN')) {
253 253
 			return true;
254 254
 		}
255 255
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			return true;
273 273
 		}
274 274
 
275
-		return (bool)$this->Environments()->filterByCallback(function($env) use($member) {
275
+		return (bool) $this->Environments()->filterByCallback(function($env) use($member) {
276 276
 			return $env->canRestore($member);
277 277
 		})->Count();
278 278
 	}
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			return true;
293 293
 		}
294 294
 
295
-		return (bool)$this->Environments()->filterByCallback(function($env) use($member) {
295
+		return (bool) $this->Environments()->filterByCallback(function($env) use($member) {
296 296
 			return $env->canBackup($member);
297 297
 		})->Count();
298 298
 	}
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 			return true;
313 313
 		}
314 314
 
315
-		return (bool)$this->Environments()->filterByCallback(function($env) use($member) {
315
+		return (bool) $this->Environments()->filterByCallback(function($env) use($member) {
316 316
 			return $env->canUploadArchive($member);
317 317
 		})->Count();
318 318
 	}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			return true;
333 333
 		}
334 334
 
335
-		return (bool)$this->Environments()->filterByCallback(function($env) use($member) {
335
+		return (bool) $this->Environments()->filterByCallback(function($env) use($member) {
336 336
 			return $env->canDownloadArchive($member);
337 337
 		})->Count();
338 338
 	}
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	public function canCreateEnvironments($member = null) {
351 351
 		$envType = $this->AllowedEnvironmentType;
352
-		if($envType) {
352
+		if ($envType) {
353 353
 			$env = Injector::inst()->get($envType);
354
-			if($env instanceof EnvironmentCreateBackend) {
354
+			if ($env instanceof EnvironmentCreateBackend) {
355 355
 				return $this->allowed(DNRoot::ALLOW_CREATE_ENVIRONMENT, $member);
356 356
 			}
357 357
 		}
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	 * @return array
388 388
 	 */
389 389
 	public function getProcessEnv() {
390
-		if(file_exists($this->getPrivateKeyPath())) {
390
+		if (file_exists($this->getPrivateKeyPath())) {
391 391
 			// Key-pair is available, use it.
392 392
 			$processEnv = array(
393 393
 				'IDENT_KEY' => $this->getPrivateKeyPath(),
394
-				'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh"
394
+				'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh"
395 395
 			);
396 396
 		} else {
397 397
 			$processEnv = array();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	 * @return DNBranchList
433 433
 	 */
434 434
 	public function DNBranchList() {
435
-		if($this->CVSPath && !$this->repoExists()) {
435
+		if ($this->CVSPath && !$this->repoExists()) {
436 436
 			$this->cloneRepo();
437 437
 		}
438 438
 		return DNBranchList::create($this, $this->DNData());
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * @return DNReferenceList
445 445
 	 */
446 446
 	public function DNTagList() {
447
-		if($this->CVSPath && !$this->repoExists()) {
447
+		if ($this->CVSPath && !$this->repoExists()) {
448 448
 			$this->cloneRepo();
449 449
 		}
450 450
 		return DNReferenceList::create($this, $this->DNData(), null, null, true);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 * @return false|Gitonomy\Git\Repository
455 455
 	 */
456 456
 	public function getRepository() {
457
-		if(!$this->repoExists()) {
457
+		if (!$this->repoExists()) {
458 458
 			return false;
459 459
 		}
460 460
 
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
 	 */
470 470
 	public function DNEnvironmentList() {
471 471
 
472
-		if(!self::$_current_member_cache) {
472
+		if (!self::$_current_member_cache) {
473 473
 			self::$_current_member_cache = Member::currentUser();
474 474
 		}
475 475
 
476
-		if(self::$_current_member_cache === false) {
476
+		if (self::$_current_member_cache === false) {
477 477
 			return new ArrayList();
478 478
 		}
479 479
 
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	 * @return false|DNDeployment
499 499
 	 */
500 500
 	public function currentBuilds() {
501
-		if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) {
501
+		if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) {
502 502
 			$currentBuilds = array();
503
-			foreach($this->Environments() as $env) {
503
+			foreach ($this->Environments() as $env) {
504 504
 				$currentBuilds[$env->Name] = $env->CurrentBuild();
505 505
 			}
506 506
 			self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	 * @return string|null
521 521
 	 */
522 522
 	public function CreateEnvironmentLink() {
523
-		if($this->canCreateEnvironments()) {
523
+		if ($this->canCreateEnvironments()) {
524 524
 			return $this->Link('createenv');
525 525
 		}
526 526
 		return null;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	public function IsStarred() {
540 540
 		$member = Member::currentUser();
541
-		if($member === null) {
541
+		if ($member === null) {
542 542
 			return false;
543 543
 		}
544 544
 		$favourited = $this->StarredBy()->filter('MemberID', $member->ID);
545
-		if($favourited->count() == 0) {
545
+		if ($favourited->count() == 0) {
546 546
 			return false;
547 547
 		}
548 548
 		return true;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 
598 598
 		$environmentTypes = ClassInfo::implementorsOf('EnvironmentCreateBackend');
599 599
 		$types = array();
600
-		foreach($environmentTypes as $type) {
600
+		foreach ($environmentTypes as $type) {
601 601
 			$types[$type] = $type;
602 602
 		}
603 603
 
@@ -621,11 +621,11 @@  discard block
 block discarded – undo
621 621
 	 */
622 622
 	public function setCreateProjectFolderField(&$fields) {
623 623
 		// Check if the capistrano project folder exists
624
-		if(!$this->Name) {
624
+		if (!$this->Name) {
625 625
 			return;
626 626
 		}
627 627
 
628
-		if($this->projectFolderExists()) {
628
+		if ($this->projectFolderExists()) {
629 629
 			return;
630 630
 		}
631 631
 
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	 */
658 658
 	public function cloneRepo() {
659 659
 		// Avoid this being called multiple times in the same request
660
-		if(!isset(self::$has_cloned_cache[$this->ID])) {
660
+		if (!isset(self::$has_cloned_cache[$this->ID])) {
661 661
 			$fetch = DNGitFetch::create();
662 662
 			$fetch->ProjectID = $this->ID;
663 663
 			$fetch->write();
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	public function onBeforeWrite() {
682 682
 		parent::onBeforeWrite();
683 683
 
684
-		if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) {
684
+		if ($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) {
685 685
 			mkdir($this->getProjectFolderPath());
686 686
 		}
687 687
 	}
@@ -689,12 +689,12 @@  discard block
 block discarded – undo
689 689
 	public function onAfterWrite() {
690 690
 		parent::onAfterWrite();
691 691
 
692
-		if(!$this->CVSPath) {
692
+		if (!$this->CVSPath) {
693 693
 			return;
694 694
 		}
695 695
 
696 696
 		$changedFields = $this->getChangedFields(true, 2);
697
-		if(isset($changedFields['CVSPath']) || isset($changedFields['Name'])) {
697
+		if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) {
698 698
 			$this->cloneRepo();
699 699
 		}
700 700
 	}
@@ -706,22 +706,22 @@  discard block
 block discarded – undo
706 706
 		parent::onAfterDelete();
707 707
 
708 708
 		// Delete related environments
709
-		foreach($this->Environments() as $env) {
709
+		foreach ($this->Environments() as $env) {
710 710
 			$env->delete();
711 711
 		}
712 712
 
713 713
 		// Delete local repository
714
-		if(file_exists($this->getLocalCVSPath())) {
714
+		if (file_exists($this->getLocalCVSPath())) {
715 715
 			Filesystem::removeFolder($this->getLocalCVSPath());
716 716
 		}
717 717
 
718 718
 		// Delete project template
719
-		if(file_exists($this->getProjectFolderPath()) && Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
719
+		if (file_exists($this->getProjectFolderPath()) && Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
720 720
 			Filesystem::removeFolder($this->getProjectFolderPath());
721 721
 		}
722 722
 
723 723
 		// Delete the deploy key
724
-		if(file_exists($this->getKeyDir())) {
724
+		if (file_exists($this->getKeyDir())) {
725 725
 			Filesystem::removeFolder($this->getKeyDir());
726 726
 		}
727 727
 	}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	public function getPublicKey() {
735 735
 		$key = $this->getPublicKeyPath();
736 736
 
737
-		if(file_exists($key)) {
737
+		if (file_exists($key)) {
738 738
 			return trim(file_get_contents($key));
739 739
 		}
740 740
 	}
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 	 * @return string|null
746 746
 	 */
747 747
 	public function getPublicKeyPath() {
748
-		if($privateKey = $this->getPrivateKeyPath()) {
749
-			return $privateKey . '.pub';
748
+		if ($privateKey = $this->getPrivateKeyPath()) {
749
+			return $privateKey.'.pub';
750 750
 		}
751 751
 		return null;
752 752
 	}
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
 	public function getPrivateKeyPath() {
760 760
 		$keyDir = $this->getKeyDir();
761
-		if(!empty($keyDir)) {
761
+		if (!empty($keyDir)) {
762 762
 			$filter = FileNameFilter::create();
763 763
 			$name = $filter->filter($this->Name);
764
-			return $keyDir . '/' . $name;
764
+			return $keyDir.'/'.$name;
765 765
 		}
766 766
 		return null;
767 767
 	}
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
 	 */
774 774
 	public function getKeyDir() {
775 775
 		$keyDir = $this->DNData()->getKeyDir();
776
-		if(!$keyDir) {
776
+		if (!$keyDir) {
777 777
 			return null;
778 778
 		}
779 779
 
780 780
 		$filter = FileNameFilter::create();
781 781
 		$name = $filter->filter($this->Name);
782 782
 
783
-		return $this->DNData()->getKeyDir() . '/' . $name;
783
+		return $this->DNData()->getKeyDir().'/'.$name;
784 784
 	}
785 785
 
786 786
 	/**
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 	 * @param GridField $environments
791 791
 	 */
792 792
 	protected function setEnvironmentFields(&$fields, $environments) {
793
-		if(!$environments) {
793
+		if (!$environments) {
794 794
 			return;
795 795
 		}
796 796
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		$environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
800 800
 		$environments->getConfig()->removeComponentsByType('GridFieldDeleteAction');
801 801
 		$environments->getConfig()->removeComponentsByType('GridFieldPageCount');
802
-		if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
802
+		if (Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
803 803
 			$addNewRelease = new GridFieldAddNewButton('toolbar-header-right');
804 804
 			$addNewRelease->setButtonName('Add');
805 805
 			$environments->getConfig()->addComponent($addNewRelease);
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	 */
816 816
 	public function getRepositoryURL() {
817 817
 		$showUrl = Config::inst()->get($this->class, 'show_repository_url');
818
-		if($showUrl) {
818
+		if ($showUrl) {
819 819
 			return $this->CVSPath;
820 820
 		}
821 821
 	}
@@ -867,9 +867,9 @@  discard block
 block discarded – undo
867 867
 		$interfaces = $this->config()->repository_interfaces;
868 868
 
869 869
 		/* Look for each whitelisted hostname */
870
-		foreach($interfaces as $host => $interface) {
870
+		foreach ($interfaces as $host => $interface) {
871 871
 			/* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */
872
-			if(preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
872
+			if (preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
873 873
 
874 874
 				$path = $match[2];
875 875
 
@@ -879,13 +879,13 @@  discard block
 block discarded – undo
879 879
 
880 880
 				$components = explode('.', $host);
881 881
 
882
-				foreach($regex as $pattern => $replacement) {
883
-					$path = preg_replace('/' . $pattern . '/', $replacement, $path);
882
+				foreach ($regex as $pattern => $replacement) {
883
+					$path = preg_replace('/'.$pattern.'/', $replacement, $path);
884 884
 				}
885 885
 
886
-				$uxurl = Controller::join_links($scheme . '://', $host, $path);
886
+				$uxurl = Controller::join_links($scheme.'://', $host, $path);
887 887
 
888
-				if(array_key_exists('commit', $interface) && $interface['commit'] == false) {
888
+				if (array_key_exists('commit', $interface) && $interface['commit'] == false) {
889 889
 					$commiturl = false;
890 890
 				} else {
891 891
 					$commiturl = Controller::join_links(
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	 * @return SS_List
930 930
 	 */
931 931
 	public function whoIsAllowedAny($codes) {
932
-		if(!is_array($codes)) $codes = array($codes);
932
+		if (!is_array($codes)) $codes = array($codes);
933 933
 
934 934
 		$SQLa_codes = Convert::raw2sql($codes);
935 935
 		$SQL_codes = join("','", $SQLa_codes);
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	public function groupAllowed($permissionCode, Group $group) {
970 970
 		$viewers = $this->Viewers();
971
-		if(!$viewers->find('ID', $group->ID)) {
971
+		if (!$viewers->find('ID', $group->ID)) {
972 972
 			return false;
973 973
 		}
974 974
 		$groups = Permission::get_groups_by_permission($permissionCode);
975
-		if(!$groups->find('ID', $group->ID)) {
975
+		if (!$groups->find('ID', $group->ID)) {
976 976
 			return false;
977 977
 		}
978 978
 		return true;
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
 			$member = Member::currentUser();
992 992
 		}
993 993
 
994
-		if(Permission::checkMember($member, 'ADMIN')) return true;
994
+		if (Permission::checkMember($member, 'ADMIN')) return true;
995 995
 
996 996
 		$hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count();
997
-		return ($hits>0 ? true : false);
997
+		return ($hits > 0 ? true : false);
998 998
 	}
999 999
 
1000 1000
 	/**
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 	 * @return bool
1004 1004
 	 */
1005 1005
 	public function isProjectReady() {
1006
-		if($this->getRunningInitialEnvironmentCreations()->count() > 0) {
1006
+		if ($this->getRunningInitialEnvironmentCreations()->count() > 0) {
1007 1007
 			// We're still creating the initial environments for this project so we're
1008 1008
 			// not quite done
1009 1009
 			return false;
@@ -1012,13 +1012,13 @@  discard block
 block discarded – undo
1012 1012
 		// Provide a hook for further checks. Logic stolen from
1013 1013
 		// {@see DataObject::extendedCan()}
1014 1014
 		$isDone = $this->extend('isProjectReady');
1015
-		if($isDone && is_array($isDone)) {
1015
+		if ($isDone && is_array($isDone)) {
1016 1016
 			$isDone = array_filter($isDone, function($val) {
1017 1017
 				return !is_null($val);
1018 1018
 			});
1019 1019
 
1020 1020
 			// If anything returns false then we're not ready.
1021
-			if($isDone) return min($isDone);
1021
+			if ($isDone) return min($isDone);
1022 1022
 		}
1023 1023
 
1024 1024
 		return true;
@@ -1068,25 +1068,25 @@  discard block
 block discarded – undo
1068 1068
 	 */
1069 1069
 	protected function validate() {
1070 1070
 		$validation = parent::validate();
1071
-		if($validation->valid()) {
1072
-			if(empty($this->Name)) {
1071
+		if ($validation->valid()) {
1072
+			if (empty($this->Name)) {
1073 1073
 				return $validation->error('The stack must have a name.');
1074 1074
 			}
1075 1075
 
1076 1076
 			// The name is used to build filepaths so should be restricted
1077
-			if(!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+$/', $this->Name)) {
1077
+			if (!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+$/', $this->Name)) {
1078 1078
 				return $validation->error('Project name can only contain alphanumeric, hyphens and underscores.');
1079 1079
 			}
1080 1080
 
1081
-			if(empty($this->CVSPath)) {
1081
+			if (empty($this->CVSPath)) {
1082 1082
 				return $validation->error('You must provide a repository URL.');
1083 1083
 			}
1084 1084
 
1085 1085
 			$existing = DNProject::get()->filter('Name', $this->Name);
1086
-			if($this->ID) {
1086
+			if ($this->ID) {
1087 1087
 				$existing = $existing->exclude('ID', $this->ID);
1088 1088
 			}
1089
-			if($existing->count() > 0) {
1089
+			if ($existing->count() > 0) {
1090 1090
 				return $validation->error('A stack already exists with that name.');
1091 1091
 			}
1092 1092
 		}
@@ -1099,10 +1099,10 @@  discard block
 block discarded – undo
1099 1099
 	 * @return bool
1100 1100
 	 */
1101 1101
 	public function canCreate($member = null) {
1102
-		if(!$member) $member = Member::currentUser();
1103
-		if(!$member) return false;
1102
+		if (!$member) $member = Member::currentUser();
1103
+		if (!$member) return false;
1104 1104
 
1105
-		if(Permission::checkMember($member, 'ADMIN')) {
1105
+		if (Permission::checkMember($member, 'ADMIN')) {
1106 1106
 			return true;
1107 1107
 		}
1108 1108
 
Please login to merge, or discard this patch.
code/backends/DeploymentStrategy.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,8 +110,12 @@
 block discarded – undo
110 110
 		// Normalise "empty" values into dashes so comparisons are done properly.
111 111
 		// This means there is no diference between an empty string and a null
112 112
 		// but "0" is considered to be non-empty.
113
-		if(empty($from) && !strlen($from)) $from = '-';
114
-		if(empty($to) && !strlen($to)) $to = '-';
113
+		if(empty($from) && !strlen($from)) {
114
+			$from = '-';
115
+		}
116
+		if(empty($to) && !strlen($to)) {
117
+			$to = '-';
118
+		}
115 119
 
116 120
 		return $this->changes[$title] = array(
117 121
 			'from' => $from,
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 		// Normalise "empty" values into dashes so comparisons are done properly.
111 111
 		// This means there is no diference between an empty string and a null
112 112
 		// but "0" is considered to be non-empty.
113
-		if(empty($from) && !strlen($from)) $from = '-';
114
-		if(empty($to) && !strlen($to)) $to = '-';
113
+		if (empty($from) && !strlen($from)) $from = '-';
114
+		if (empty($to) && !strlen($to)) $to = '-';
115 115
 
116 116
 		return $this->changes[$title] = array(
117 117
 			'from' => $from,
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public function getChange($key) {
172 172
 		$changes = $this->getChanges();
173
-		if(array_key_exists($key, $changes)) {
173
+		if (array_key_exists($key, $changes)) {
174 174
 			return new ArrayData($changes[$key]);
175 175
 		}
176 176
 		return null;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return string|null
190 190
 	 */
191 191
 	public function getOption($option) {
192
-		if(!empty($this->options[$option])) {
192
+		if (!empty($this->options[$option])) {
193 193
 			return $this->options[$option];
194 194
 		}
195 195
 	}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 			DeploymentStrategy::WARNING_CODE => 1,
231 231
 			DeploymentStrategy::ERROR_CODE => 2
232 232
 		];
233
-		if($map[$current] < $map[$code]) {
233
+		if ($map[$current] < $map[$code]) {
234 234
 			$this->setValidationCode($code);
235 235
 		}
236 236
 	}
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		);
260 260
 
261 261
 		$output = array();
262
-		foreach($fields as $field) {
262
+		foreach ($fields as $field) {
263 263
 			$output[$field] = $this->$field;
264 264
 		}
265 265
 		return $output;
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 			'messages'
301 301
 		);
302 302
 
303
-		foreach($fields as $field) {
304
-			if(!empty($data[$field])) {
303
+		foreach ($fields as $field) {
304
+			if (!empty($data[$field])) {
305 305
 				$this->$field = $data[$field];
306 306
 			}
307 307
 		}
Please login to merge, or discard this patch.
code/jobs/PingJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	 * Do the actual job by calling the appropiate backend
32 32
 	 */
33 33
 	public function perform() {
34
-		echo "[-] PingJob starting" . PHP_EOL;
34
+		echo "[-] PingJob starting".PHP_EOL;
35 35
 		$log = new DeploynautLogFile($this->args['logfile']);
36 36
 
37 37
 		$ping = DNPing::get()->byID($this->args['pingID']);
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -205,12 +205,16 @@
 block discarded – undo
205 205
 	 */
206 206
 	public function getFullDeployMessages() {
207 207
 		$strategy = $this->getDeploymentStrategy();
208
-		if ($strategy->getActionCode()!=='full') return null;
208
+		if ($strategy->getActionCode()!=='full') {
209
+			return null;
210
+		}
209 211
 
210 212
 		$changes = $strategy->getChangesModificationNeeded();
211 213
 		$messages = [];
212 214
 		foreach ($changes as $change => $details) {
213
-			if ($change==='Code version') continue;
215
+			if ($change==='Code version') {
216
+				continue;
217
+			}
214 218
 
215 219
 			$messages[] = [
216 220
 				'Flag' => sprintf(
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public function LogLink() {
104
-		return $this->Link() . '/log';
104
+		return $this->Link().'/log';
105 105
 	}
106 106
 
107 107
 	public function canView($member = null) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return \Gitonomy\Git\Repository|null
148 148
 	 */
149 149
 	public function getRepository() {
150
-		if(!$this->SHA) {
150
+		if (!$this->SHA) {
151 151
 			return null;
152 152
 		}
153 153
 		return $this->Environment()->Project()->getRepository();
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function getCommit() {
162 162
 		$repo = $this->getRepository();
163
-		if($repo) {
163
+		if ($repo) {
164 164
 			try {
165 165
 				return $repo->getCommit($this->SHA);
166
-			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
166
+			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
167 167
 				return null;
168 168
 			}
169 169
 		}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		if (!$interface) {
189 189
 			return null;
190 190
 		}
191
-		return $interface->CommitURL . '/' . $this->SHA;
191
+		return $interface->CommitURL.'/'.$this->SHA;
192 192
 	}
193 193
 
194 194
 	/**
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function getCommitMessage() {
200 200
 		$commit = $this->getCommit();
201
-		if($commit) {
201
+		if ($commit) {
202 202
 			try {
203 203
 				return Convert::raw2xml($commit->getMessage());
204
-			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
204
+			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
205 205
 				return null;
206 206
 			}
207 207
 		}
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	public function getTags() {
217 217
 		$returnTags = array();
218 218
 		$repo = $this->getRepository();
219
-		if($repo) {
219
+		if ($repo) {
220 220
 			$tags = $repo->getReferences()->resolveTags($this->SHA);
221
-			if(!empty($tags)) {
222
-				foreach($tags as $tag) {
221
+			if (!empty($tags)) {
222
+				foreach ($tags as $tag) {
223 223
 					$field = Varchar::create('Tag', '255');
224 224
 					$field->setValue($tag->getName());
225 225
 					$returnTags[] = $field;
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function getFullDeployMessages() {
239 239
 		$strategy = $this->getDeploymentStrategy();
240
-		if ($strategy->getActionCode()!=='full') return null;
240
+		if ($strategy->getActionCode() !== 'full') return null;
241 241
 
242 242
 		$changes = $strategy->getChangesModificationNeeded();
243 243
 		$messages = [];
244 244
 		foreach ($changes as $change => $details) {
245
-			if ($change==='Code version') continue;
245
+			if ($change === 'Code version') continue;
246 246
 
247 247
 			$messages[] = [
248 248
 				'Flag' => sprintf(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	public function getTag() {
272 272
 		$tags = $this->getTags();
273
-		if($tags->count() > 0) {
273
+		if ($tags->count() > 0) {
274 274
 			return $tags->last();
275 275
 		}
276 276
 		return null;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	public function getChanges() {
296 296
 		$list = new ArrayList();
297 297
 		$strategy = $this->getDeploymentStrategy();
298
-		foreach($strategy->getChanges() as $name => $change) {
298
+		foreach ($strategy->getChanges() as $name => $change) {
299 299
 			$changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null;
300 300
 			$description = isset($change['description']) ? $change['description'] : '';
301 301
 			$compareUrl = null;
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 		// Make sure we use the SHA as it was written into this DNDeployment.
346 346
 		$args['sha'] = $this->SHA;
347 347
 
348
-		if(!$this->DeployerID) {
348
+		if (!$this->DeployerID) {
349 349
 			$this->DeployerID = Member::currentUserID();
350 350
 		}
351 351
 
352
-		if($this->DeployerID) {
352
+		if ($this->DeployerID) {
353 353
 			$deployer = $this->Deployer();
354 354
 			$message = sprintf(
355 355
 				'Deploy to %s initiated by %s (%s), with IP address %s',
Please login to merge, or discard this patch.
code/control/DeployForm.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 				substr($sha, 0, 8),
74 74
 				$branch->LastUpdated()->TimeDiff()
75 75
 			);
76
-			$branches[$sha . '-' . $name] = $branchValue;
76
+			$branches[$sha.'-'.$name] = $branchValue;
77 77
 		}
78 78
 
79 79
 		// Tags
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 				substr($sha, 0, 8),
87 87
 				$branch->LastUpdated()->TimeDiff()
88 88
 			);
89
-			$tags[$sha . '-' . $tag] = $tagValue;
89
+			$tags[$sha.'-'.$tag] = $tagValue;
90 90
 		}
91 91
 		$tags = array_reverse($tags);
92 92
 
Please login to merge, or discard this patch.
code/model/StateMachineFactory.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@
 block discarded – undo
58 58
 
59 59
 	protected function addHandlers($machine) {
60 60
 		$class = get_class($machine->getObject());
61
-		if (empty($this->config()->handlers[$class])) return;
61
+		if (empty($this->config()->handlers[$class])) {
62
+			return;
63
+		}
62 64
 
63 65
 		$transitions = $this->config()->handlers[$class];
64 66
 		foreach ($transitions as $transName => $handlers) {
Please login to merge, or discard this patch.
_config.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
 // This will ensure jobs can correctly clean themselves up on any type of failure
11 11
 Resque_Event::listen('onFailure', function(Exception $exception, Resque_job $job) {
12 12
 	$inst = $job->getInstance();
13
-	if($inst instanceof DeploynautJobInterface) {
13
+	if ($inst instanceof DeploynautJobInterface) {
14 14
 		$inst->onFailure($exception);
15 15
 	}
16 16
 });
Please login to merge, or discard this patch.
code/control/EnvironmentOverview.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@
 block discarded – undo
63 63
 		$base = Director::absoluteBaseURL();
64 64
 		return [
65 65
 			'dispatchers' => [
66
-				'git' => $base . $this->getCurrentProject()->Link('git'),
67
-				'plan' => $base . $this->getCurrentEnvironment()->Link('plan'),
68
-				'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys')
66
+				'git' => $base.$this->getCurrentProject()->Link('git'),
67
+				'plan' => $base.$this->getCurrentEnvironment()->Link('plan'),
68
+				'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys')
69 69
 			],
70 70
 			'api_auth' => [
71 71
 				'name' => $this->getSecurityToken()->getName(),
Please login to merge, or discard this patch.
code/control/DNDeploymentDispatcher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
 		// It gives a chance to perform a dry-run, and reject the transition, for example
97 97
 		// in case the user is unauthorised.
98 98
 			'finite.test_transition',
99
-			function (Finite\Event\TransitionEvent $e) use ($project) {
99
+			function(Finite\Event\TransitionEvent $e) use ($project) {
100 100
 				$code = null;
101 101
 
102 102
 				switch ($e->getTransition()->getName()) {
Please login to merge, or discard this patch.