@@ -49,7 +49,10 @@ |
||
49 | 49 | 'projects' => array(), |
50 | 50 | ); |
51 | 51 | |
52 | - if($request->httpMethod() != 'GET') return $this->message('API not found', 404);; |
|
52 | + if($request->httpMethod() != 'GET') { |
|
53 | + return $this->message('API not found', 404); |
|
54 | + } |
|
55 | + ; |
|
53 | 56 | |
54 | 57 | foreach(DNProject::get() as $item) { |
55 | 58 | if($item->canView($this->getMember())) { |
@@ -176,7 +176,9 @@ |
||
176 | 176 | $name = $environment->getFullName(); |
177 | 177 | $env = $environment->Project()->getProcessEnv(); |
178 | 178 | |
179 | - if(!$args) $args = array(); |
|
179 | + if(!$args) { |
|
180 | + $args = array(); |
|
181 | + } |
|
180 | 182 | $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
181 | 183 | |
182 | 184 | // Inject env string directly into the command. |
@@ -33,7 +33,9 @@ |
||
33 | 33 | */ |
34 | 34 | public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { |
35 | 35 | $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); |
36 | - if(!file_exists($tempPath)) mkdir($tempPath); |
|
36 | + if(!file_exists($tempPath)) { |
|
37 | + mkdir($tempPath); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // Execute these in sequence until there's a failure |
39 | 41 | $processes = array( |
@@ -41,16 +41,22 @@ discard block |
||
41 | 41 | * @param DeploynautLogFile $log The log to write status output to, including package-generation commands |
42 | 42 | */ |
43 | 43 | public function getPackageFilename(PackageGenerator $generator, $identifier, $sha, $repositoryDir, DeploynautLogFile $log) { |
44 | - if(!$this->baseDir) throw new \LogicException("Can't use PackageCache without setting BaseDir"); |
|
44 | + if(!$this->baseDir) { |
|
45 | + throw new \LogicException("Can't use PackageCache without setting BaseDir"); |
|
46 | + } |
|
45 | 47 | |
46 | 48 | $buildPath = $this->baseDir . '/' . $this->sanitiseDirName($identifier); |
47 | 49 | $filename = "$buildPath/$sha.tar.gz"; |
48 | 50 | |
49 | 51 | if(!file_exists($this->baseDir)) { |
50 | - if(!mkdir($this->baseDir)) throw new \LogicException("Can't create base dir {$this->baseDir}"); |
|
52 | + if(!mkdir($this->baseDir)) { |
|
53 | + throw new \LogicException("Can't create base dir {$this->baseDir}"); |
|
54 | + } |
|
51 | 55 | } |
52 | 56 | if(!file_exists($buildPath)) { |
53 | - if(!mkdir($buildPath)) throw new \LogicException("Can't create build path $buildPath"); |
|
57 | + if(!mkdir($buildPath)) { |
|
58 | + throw new \LogicException("Can't create build path $buildPath"); |
|
59 | + } |
|
54 | 60 | } |
55 | 61 | |
56 | 62 | if(file_exists($filename)) { |
@@ -61,7 +67,9 @@ discard block |
||
61 | 67 | return $filename; |
62 | 68 | |
63 | 69 | } else { |
64 | - if($this->cacheSize) $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log); |
|
70 | + if($this->cacheSize) { |
|
71 | + $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log); |
|
72 | + } |
|
65 | 73 | |
66 | 74 | if($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { |
67 | 75 | return $filename; |
@@ -107,11 +107,15 @@ discard block |
||
107 | 107 | * @return boolean |
108 | 108 | */ |
109 | 109 | public static function FlagSnapshotsEnabled() { |
110 | - if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) return true; |
|
110 | + if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
111 | + return true; |
|
112 | + } |
|
111 | 113 | if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
112 | 114 | $allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS); |
113 | 115 | $member = Member::currentUser(); |
114 | - if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) return true; |
|
116 | + if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
117 | + return true; |
|
118 | + } |
|
115 | 119 | } |
116 | 120 | return false; |
117 | 121 | } |
@@ -655,14 +659,22 @@ discard block |
||
655 | 659 | $params = $request->params(); |
656 | 660 | $pipeline = Pipeline::get()->byID($params['Identifier']); |
657 | 661 | |
658 | - if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) throw new SS_HTTPResponse_Exception('Pipeline not found', 404); |
|
659 | - if(!$pipeline->Environment()->canView()) return Security::permissionFailure(); |
|
662 | + if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) { |
|
663 | + throw new SS_HTTPResponse_Exception('Pipeline not found', 404); |
|
664 | + } |
|
665 | + if(!$pipeline->Environment()->canView()) { |
|
666 | + return Security::permissionFailure(); |
|
667 | + } |
|
660 | 668 | |
661 | 669 | $environment = $pipeline->Environment(); |
662 | 670 | $project = $pipeline->Environment()->Project(); |
663 | 671 | |
664 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this pipeline"); |
|
665 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this pipeline"); |
|
672 | + if($environment->Name != $params['Environment']) { |
|
673 | + throw new LogicException("Environment in URL doesn't match this pipeline"); |
|
674 | + } |
|
675 | + if($project->Name != $params['Project']) { |
|
676 | + throw new LogicException("Project in URL doesn't match this pipeline"); |
|
677 | + } |
|
666 | 678 | |
667 | 679 | // Delegate to sub-requesthandler |
668 | 680 | return PipelineController::create($this, $pipeline); |
@@ -795,14 +807,22 @@ discard block |
||
795 | 807 | $params = $request->params(); |
796 | 808 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
797 | 809 | |
798 | - if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
799 | - if(!$deployment->canView()) return Security::permissionFailure(); |
|
810 | + if(!$deployment || !$deployment->ID) { |
|
811 | + throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
812 | + } |
|
813 | + if(!$deployment->canView()) { |
|
814 | + return Security::permissionFailure(); |
|
815 | + } |
|
800 | 816 | |
801 | 817 | $environment = $deployment->Environment(); |
802 | 818 | $project = $environment->Project(); |
803 | 819 | |
804 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); |
|
805 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
820 | + if($environment->Name != $params['Environment']) { |
|
821 | + throw new LogicException("Environment in URL doesn't match this deploy"); |
|
822 | + } |
|
823 | + if($project->Name != $params['Project']) { |
|
824 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
825 | + } |
|
806 | 826 | |
807 | 827 | return $this->customise(new ArrayData(array( |
808 | 828 | 'Deployment' => $deployment, |
@@ -818,14 +838,22 @@ discard block |
||
818 | 838 | $params = $request->params(); |
819 | 839 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
820 | 840 | |
821 | - if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
822 | - if(!$deployment->canView()) return Security::permissionFailure(); |
|
841 | + if(!$deployment || !$deployment->ID) { |
|
842 | + throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
843 | + } |
|
844 | + if(!$deployment->canView()) { |
|
845 | + return Security::permissionFailure(); |
|
846 | + } |
|
823 | 847 | |
824 | 848 | $environment = $deployment->Environment(); |
825 | 849 | $project = $environment->Project(); |
826 | 850 | |
827 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); |
|
828 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
851 | + if($environment->Name != $params['Environment']) { |
|
852 | + throw new LogicException("Environment in URL doesn't match this deploy"); |
|
853 | + } |
|
854 | + if($project->Name != $params['Project']) { |
|
855 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
856 | + } |
|
829 | 857 | |
830 | 858 | $log = $deployment->log(); |
831 | 859 | if($log->exists()) { |
@@ -950,13 +978,19 @@ discard block |
||
950 | 978 | $params = $request->params(); |
951 | 979 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
952 | 980 | |
953 | - if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
954 | - if(!$transfer->canView()) return Security::permissionFailure(); |
|
981 | + if(!$transfer || !$transfer->ID) { |
|
982 | + throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
983 | + } |
|
984 | + if(!$transfer->canView()) { |
|
985 | + return Security::permissionFailure(); |
|
986 | + } |
|
955 | 987 | |
956 | 988 | $environment = $transfer->Environment(); |
957 | 989 | $project = $environment->Project(); |
958 | 990 | |
959 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
991 | + if($project->Name != $params['Project']) { |
|
992 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
993 | + } |
|
960 | 994 | |
961 | 995 | return $this->customise(new ArrayData(array( |
962 | 996 | 'Transfer' => $transfer, |
@@ -973,13 +1007,19 @@ discard block |
||
973 | 1007 | $params = $request->params(); |
974 | 1008 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
975 | 1009 | |
976 | - if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
977 | - if(!$transfer->canView()) return Security::permissionFailure(); |
|
1010 | + if(!$transfer || !$transfer->ID) { |
|
1011 | + throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
1012 | + } |
|
1013 | + if(!$transfer->canView()) { |
|
1014 | + return Security::permissionFailure(); |
|
1015 | + } |
|
978 | 1016 | |
979 | 1017 | $environment = $transfer->Environment(); |
980 | 1018 | $project = $environment->Project(); |
981 | 1019 | |
982 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
1020 | + if($project->Name != $params['Project']) { |
|
1021 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
1022 | + } |
|
983 | 1023 | |
984 | 1024 | $log = $transfer->log(); |
985 | 1025 | if($log->exists()) { |
@@ -1318,7 +1358,9 @@ discard block |
||
1318 | 1358 | * @return DNEnvironment |
1319 | 1359 | */ |
1320 | 1360 | protected function getCurrentEnvironment($project = null) { |
1321 | - if(!$project) $project = $this->getCurrentProject(); |
|
1361 | + if(!$project) { |
|
1362 | + $project = $this->getCurrentProject(); |
|
1363 | + } |
|
1322 | 1364 | return $project->DNEnvironmentList()->filter('Name', $this->getRequest()->latestParam('Environment'))->First(); |
1323 | 1365 | } |
1324 | 1366 | |
@@ -1333,12 +1375,18 @@ discard block |
||
1333 | 1375 | * @return boolean true if $member has access to upload or download to at least one {@link DNEnvironment}. |
1334 | 1376 | */ |
1335 | 1377 | public function CanViewArchives(Member $member = null) { |
1336 | - if(!$member) $member = Member::currentUser(); |
|
1378 | + if(!$member) { |
|
1379 | + $member = Member::currentUser(); |
|
1380 | + } |
|
1337 | 1381 | |
1338 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
1382 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
1383 | + return true; |
|
1384 | + } |
|
1339 | 1385 | |
1340 | 1386 | $allProjects = $this->DNProjectList(); |
1341 | - if(!$allProjects) return false; |
|
1387 | + if(!$allProjects) { |
|
1388 | + return false; |
|
1389 | + } |
|
1342 | 1390 | |
1343 | 1391 | foreach($allProjects as $project) { |
1344 | 1392 | if($project->Environments()) { |
@@ -1383,7 +1431,9 @@ discard block |
||
1383 | 1431 | $archives = new ArrayList(); |
1384 | 1432 | foreach($project->DNEnvironmentList() as $env) { |
1385 | 1433 | foreach($env->DataArchives() as $archive) { |
1386 | - if($archive->canView() && $archive->isPending()) $archives->push($archive); |
|
1434 | + if($archive->canView() && $archive->isPending()) { |
|
1435 | + $archives->push($archive); |
|
1436 | + } |
|
1387 | 1437 | } |
1388 | 1438 | } |
1389 | 1439 | return new PaginatedList($archives->sort("Created", "DESC"), $this->request); |
@@ -75,7 +75,9 @@ |
||
75 | 75 | * @param string $body |
76 | 76 | */ |
77 | 77 | protected function sendMessageTo($source, $from, $to, $subject, $body) { |
78 | - if($to instanceof Member) $to = $to->Email; |
|
78 | + if($to instanceof Member) { |
|
79 | + $to = $to->Email; |
|
80 | + } |
|
79 | 81 | $this->sendViaEmail($source, $from, $to, $subject, $body); |
80 | 82 | } |
81 | 83 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | class DataArchiveFileField extends FileField { |
9 | 9 | |
10 | 10 | public function saveInto(DataObjectInterface $record) { |
11 | - if(!isset($_FILES[$this->name])) return false; |
|
11 | + if(!isset($_FILES[$this->name])) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | if(!($record instanceof DNDataArchive)) { |
14 | 16 | throw new LogicException('Saving into wrong type, expected DNDataArchive'); |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | $absolutePath = $dataArchive->generateFilepath($dataTransfer); |
28 | 30 | $relativePath = preg_replace('#^' . preg_quote(ASSETS_PATH) . '/#', '', $absolutePath); |
29 | 31 | $this->upload->loadIntoFile($_FILES[$this->name], $file, $relativePath); |
30 | - if($this->upload->isError()) return false; |
|
32 | + if($this->upload->isError()) { |
|
33 | + return false; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $file = $this->upload->getFile(); |
33 | 37 | if($this->relationAutoSetting) { |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | if(file_exists($path)) { |
32 | 32 | $command = array(); |
33 | - if($user) $command[] = sprintf('sudo -u %s', $user); |
|
33 | + if($user) { |
|
34 | + $command[] = sprintf('sudo -u %s', $user); |
|
35 | + } |
|
34 | 36 | $command[] = sprintf('rm -rf %s', $path); |
35 | 37 | |
36 | 38 | fwrite($fh, sprintf('[%s] Cleaning up existing repository %s', date('Y-m-d H:i:s'), $path) . PHP_EOL); |
@@ -50,7 +52,9 @@ discard block |
||
50 | 52 | echo "[-] CloneGitRepo starting" . PHP_EOL; |
51 | 53 | |
52 | 54 | $command = array(); |
53 | - if($user) $command[] = sprintf('sudo -u %s', $user); |
|
55 | + if($user) { |
|
56 | + $command[] = sprintf('sudo -u %s', $user); |
|
57 | + } |
|
54 | 58 | $command[] = sprintf('git clone --bare -q %s %s', $repo, $path); |
55 | 59 | |
56 | 60 | fwrite($fh, sprintf('[%s] Running command: %s', date('Y-m-d H:i:s'), implode(' ', $command)) . PHP_EOL); |
@@ -97,8 +97,11 @@ |
||
97 | 97 | * @return string |
98 | 98 | */ |
99 | 99 | public function IsOpenByDefault() { |
100 | - if($this->Name() == 'master') return " open"; |
|
101 | - else return ""; |
|
100 | + if($this->Name() == 'master') { |
|
101 | + return " open"; |
|
102 | + } else { |
|
103 | + return ""; |
|
104 | + } |
|
102 | 105 | } |
103 | 106 | |
104 | 107 | } |