@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | Requirements::javascript('deploynaut/javascript/material.js'); |
179 | 179 | |
180 | 180 | // Load the buildable dependencies only if not loaded centrally. |
181 | - if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { |
|
181 | + if (!is_dir(BASE_PATH.DIRECTORY_SEPARATOR.'static')) { |
|
182 | 182 | if (\Director::isDev()) { |
183 | 183 | \Requirements::javascript('deploynaut/static/bundle-debug.js'); |
184 | 184 | } else { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | // Block framework jquery |
245 | - Requirements::block(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); |
|
245 | + Requirements::block(FRAMEWORK_DIR.'/thirdparty/jquery/jquery.js'); |
|
246 | 246 | |
247 | 247 | self::include_requirements(); |
248 | 248 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return \SS_HTTPResponse |
262 | 262 | */ |
263 | 263 | public function index(SS_HTTPRequest $request) { |
264 | - return $this->redirect($this->Link() . 'projects/'); |
|
264 | + return $this->redirect($this->Link().'projects/'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | // Framing an environment as a "group of people with download access" |
390 | 390 | // makes more sense to the user here, while still allowing us to enforce |
391 | 391 | // environment specific restrictions on downloading the file later on. |
392 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
392 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
393 | 393 | return $item->canUploadArchive(); |
394 | 394 | }); |
395 | 395 | $envsMap = []; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $form->disableSecurityToken(); |
422 | 422 | $form->addExtraClass('fields-wide'); |
423 | 423 | // Tweak the action so it plays well with our fake URL structure. |
424 | - $form->setFormAction($project->Link() . '/UploadSnapshotForm'); |
|
424 | + $form->setFormAction($project->Link().'/UploadSnapshotForm'); |
|
425 | 425 | |
426 | 426 | return $form; |
427 | 427 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | $validEnvs = $project->DNEnvironmentList() |
445 | - ->filterByCallback(function ($item) { |
|
445 | + ->filterByCallback(function($item) { |
|
446 | 446 | return $item->canUploadArchive(); |
447 | 447 | }); |
448 | 448 | |
@@ -471,9 +471,9 @@ discard block |
||
471 | 471 | $dataArchive->DataTransfers()->add($dataTransfer); |
472 | 472 | $form->saveInto($dataArchive); |
473 | 473 | $dataArchive->write(); |
474 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
474 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
475 | 475 | |
476 | - $cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) { |
|
476 | + $cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) { |
|
477 | 477 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
478 | 478 | $process->setTimeout(120); |
479 | 479 | $process->run(); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // Framing an environment as a "group of people with download access" |
548 | 548 | // makes more sense to the user here, while still allowing us to enforce |
549 | 549 | // environment specific restrictions on downloading the file later on. |
550 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
550 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
551 | 551 | return $item->canUploadArchive(); |
552 | 552 | }); |
553 | 553 | $envsMap = []; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $form->disableSecurityToken(); |
574 | 574 | $form->addExtraClass('fields-wide'); |
575 | 575 | // Tweak the action so it plays well with our fake URL structure. |
576 | - $form->setFormAction($project->Link() . '/PostSnapshotForm'); |
|
576 | + $form->setFormAction($project->Link().'/PostSnapshotForm'); |
|
577 | 577 | |
578 | 578 | return $form; |
579 | 579 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | return $this->project404Response(); |
593 | 593 | } |
594 | 594 | |
595 | - $validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
595 | + $validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
596 | 596 | return $item->canUploadArchive(); |
597 | 597 | }); |
598 | 598 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | $branchName = $request->getVar('name'); |
713 | 713 | $branch = $project->DNBranchList()->byName($branchName); |
714 | 714 | if (!$branch) { |
715 | - return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404); |
|
715 | + return new SS_HTTPResponse("Branch '".Convert::raw2xml($branchName)."' not found.", 404); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | return $this->render([ |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | ); |
850 | 850 | |
851 | 851 | // Tweak the action so it plays well with our fake URL structure. |
852 | - $form->setFormAction($project->Link() . '/CreateEnvironmentForm'); |
|
852 | + $form->setFormAction($project->Link().'/CreateEnvironmentForm'); |
|
853 | 853 | |
854 | 854 | return $form; |
855 | 855 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $job->write(); |
883 | 883 | $job->start(); |
884 | 884 | |
885 | - return $this->redirect($project->Link('createenv') . '/' . $job->ID); |
|
885 | + return $this->redirect($project->Link('createenv').'/'.$job->ID); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | return $body; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - $form->setFormAction($this->getRequest()->getURL() . '/DeployForm'); |
|
1083 | + $form->setFormAction($this->getRequest()->getURL().'/DeployForm'); |
|
1084 | 1084 | return $form; |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | $deployment->getMachine()->apply(DNDeployment::TR_QUEUE); |
1347 | 1347 | |
1348 | 1348 | return json_encode([ |
1349 | - 'url' => Director::absoluteBaseURL() . $deployment->Link() |
|
1349 | + 'url' => Director::absoluteBaseURL().$deployment->Link() |
|
1350 | 1350 | ], JSON_PRETTY_PRINT); |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | */ |
1470 | 1470 | public function getDataTransferForm(SS_HTTPRequest $request = null) { |
1471 | 1471 | // Performs canView permission check by limiting visible projects |
1472 | - $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) { |
|
1472 | + $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) { |
|
1473 | 1473 | return $item->canBackup(); |
1474 | 1474 | }); |
1475 | 1475 | |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | ->addExtraClass('btn') |
1492 | 1492 | ) |
1493 | 1493 | ); |
1494 | - $form->setFormAction($this->getRequest()->getURL() . '/DataTransferForm'); |
|
1494 | + $form->setFormAction($this->getRequest()->getURL().'/DataTransferForm'); |
|
1495 | 1495 | |
1496 | 1496 | return $form; |
1497 | 1497 | } |
@@ -1517,12 +1517,12 @@ discard block |
||
1517 | 1517 | // Validate direction. |
1518 | 1518 | if ($data['Direction'] == 'get') { |
1519 | 1519 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
1520 | - ->filterByCallback(function ($item) { |
|
1520 | + ->filterByCallback(function($item) { |
|
1521 | 1521 | return $item->canBackup(); |
1522 | 1522 | }); |
1523 | 1523 | } else if ($data['Direction'] == 'push') { |
1524 | 1524 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
1525 | - ->filterByCallback(function ($item) { |
|
1525 | + ->filterByCallback(function($item) { |
|
1526 | 1526 | return $item->canRestore(); |
1527 | 1527 | }); |
1528 | 1528 | } else { |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | |
1654 | 1654 | // Performs canView permission check by limiting visible projects |
1655 | 1655 | $project = $this->getCurrentProject(); |
1656 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
1656 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
1657 | 1657 | return $item->canRestore(); |
1658 | 1658 | }); |
1659 | 1659 | |
@@ -1692,7 +1692,7 @@ discard block |
||
1692 | 1692 | ->addExtraClass('btn') |
1693 | 1693 | ) |
1694 | 1694 | ); |
1695 | - $form->setFormAction($project->Link() . '/DataTransferRestoreForm'); |
|
1695 | + $form->setFormAction($project->Link().'/DataTransferRestoreForm'); |
|
1696 | 1696 | |
1697 | 1697 | return $form; |
1698 | 1698 | } |
@@ -1790,7 +1790,7 @@ discard block |
||
1790 | 1790 | ->addExtraClass('btn') |
1791 | 1791 | ) |
1792 | 1792 | ); |
1793 | - $form->setFormAction($project->Link() . '/DeleteForm'); |
|
1793 | + $form->setFormAction($project->Link().'/DeleteForm'); |
|
1794 | 1794 | |
1795 | 1795 | return $form; |
1796 | 1796 | } |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | ->addExtraClass('btn') |
1897 | 1897 | ) |
1898 | 1898 | ); |
1899 | - $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm'); |
|
1899 | + $form->setFormAction($this->getCurrentProject()->Link().'/MoveForm'); |
|
1900 | 1900 | |
1901 | 1901 | return $form; |
1902 | 1902 | } |
@@ -2157,7 +2157,7 @@ discard block |
||
2157 | 2157 | $transfers = DNDataTransfer::get() |
2158 | 2158 | ->filter('EnvironmentID', $environments) |
2159 | 2159 | ->filterByCallback( |
2160 | - function ($record) { |
|
2160 | + function($record) { |
|
2161 | 2161 | return |
2162 | 2162 | $record->Environment()->canRestore() || // Ensure member can perform an action on the transfers env |
2163 | 2163 | $record->Environment()->canBackup() || |
@@ -2282,7 +2282,7 @@ discard block |
||
2282 | 2282 | */ |
2283 | 2283 | protected function project404Response() { |
2284 | 2284 | return new SS_HTTPResponse( |
2285 | - "Project '" . Convert::raw2xml($this->getRequest()->param('Project')) . "' not found.", |
|
2285 | + "Project '".Convert::raw2xml($this->getRequest()->param('Project'))."' not found.", |
|
2286 | 2286 | 404 |
2287 | 2287 | ); |
2288 | 2288 | } |
@@ -2292,7 +2292,7 @@ discard block |
||
2292 | 2292 | */ |
2293 | 2293 | protected function environment404Response() { |
2294 | 2294 | $envName = Convert::raw2xml($this->getRequest()->param('Environment')); |
2295 | - return new SS_HTTPResponse("Environment '" . $envName . "' not found.", 404); |
|
2295 | + return new SS_HTTPResponse("Environment '".$envName."' not found.", 404); |
|
2296 | 2296 | } |
2297 | 2297 | |
2298 | 2298 | /** |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $remove = true; |
10 | 10 | $dryRun = true; |
11 | 11 | |
12 | - if($request && $request->requestVar('remove') !== null) { |
|
13 | - $remove = (bool)$request->requestVar('remove'); |
|
12 | + if ($request && $request->requestVar('remove') !== null) { |
|
13 | + $remove = (bool) $request->requestVar('remove'); |
|
14 | 14 | } |
15 | 15 | |
16 | - if($request && $request->requestVar('dryrun') !== null) { |
|
17 | - $dryRun = (bool)$request->requestVar('dryrun'); |
|
16 | + if ($request && $request->requestVar('dryrun') !== null) { |
|
17 | + $dryRun = (bool) $request->requestVar('dryrun'); |
|
18 | 18 | } |
19 | 19 | |
20 | - if($dryRun) { |
|
20 | + if ($dryRun) { |
|
21 | 21 | echo "Running in dry run mode, no changes commited, "; |
22 | - echo "the output shows a prediction on what will happen." . PHP_EOL; |
|
23 | - echo "To skip dryrun, run the task like this:" . PHP_EOL; |
|
24 | - echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0" . PHP_EOL . PHP_EOL; |
|
22 | + echo "the output shows a prediction on what will happen.".PHP_EOL; |
|
23 | + echo "To skip dryrun, run the task like this:".PHP_EOL; |
|
24 | + echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0".PHP_EOL.PHP_EOL; |
|
25 | 25 | sleep(3); |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Sync projects |
32 | 32 | $projects = DNProject::get(); |
33 | - if($remove) { |
|
33 | + if ($remove) { |
|
34 | 34 | $this->echoHeader('Removing obsolete projects'); |
35 | 35 | $this->removeObsoleteProjects($projectPaths, $dryRun); |
36 | 36 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $this->syncProjectPaths($projectPaths, $dryRun); |
39 | 39 | |
40 | 40 | $this->echoHeader('Syncing environment files'); |
41 | - foreach($projects as $project) { |
|
41 | + foreach ($projects as $project) { |
|
42 | 42 | $this->echoHeader($project->Name); |
43 | 43 | // Sync environments for each project |
44 | 44 | $environmentPaths = $data->getEnvironmentPaths($project->Name); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | }, $paths); |
63 | 63 | |
64 | 64 | $removeList = $list->filter('Filename:not', $basePaths); |
65 | - if($removeList->count() === 0) { |
|
65 | + if ($removeList->count() === 0) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - foreach($removeList as $remove) { |
|
70 | - $this->message('Removing "' . basename($remove->Name) . '" from db'); |
|
71 | - if(!$dryRun) { |
|
69 | + foreach ($removeList as $remove) { |
|
70 | + $this->message('Removing "'.basename($remove->Name).'" from db'); |
|
71 | + if (!$dryRun) { |
|
72 | 72 | $removeList->remove($remove); |
73 | 73 | } |
74 | 74 | } |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function removeObsoleteProjects($paths, $dryrun = false) { |
85 | 85 | $removeList = DNProject::get()->filter('Name:not', $paths); |
86 | - if($removeList->count() == 0) { |
|
86 | + if ($removeList->count() == 0) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | - foreach($removeList as $remove) { |
|
91 | - $this->message($remove->Name . ' ' . $remove->Path); |
|
92 | - if(!$dryrun) { |
|
90 | + foreach ($removeList as $remove) { |
|
91 | + $this->message($remove->Name.' '.$remove->Path); |
|
92 | + if (!$dryrun) { |
|
93 | 93 | $removeList->remove($remove); |
94 | 94 | } |
95 | 95 | } |
@@ -106,22 +106,22 @@ discard block |
||
106 | 106 | $list = $project->Environments(); |
107 | 107 | |
108 | 108 | // Normalise paths in DB |
109 | - foreach($list as $item) { |
|
109 | + foreach ($list as $item) { |
|
110 | 110 | $real = realpath($item->Filename); |
111 | - if($real && $real != $item->Filename) { |
|
111 | + if ($real && $real != $item->Filename) { |
|
112 | 112 | $item->Filename = $real; |
113 | 113 | $item->write(); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - foreach($paths as $path) { |
|
117 | + foreach ($paths as $path) { |
|
118 | 118 | $path = basename($path); |
119 | - if($list->filter('Filename', $path)->count()) { |
|
119 | + if ($list->filter('Filename', $path)->count()) { |
|
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | |
123 | - $this->message('Adding "' . basename($path) . '" to db'); |
|
124 | - if(!$dryRun) { |
|
123 | + $this->message('Adding "'.basename($path).'" to db'); |
|
124 | + if (!$dryRun) { |
|
125 | 125 | $environment = DNEnvironment::create_from_path($path); |
126 | 126 | $environment->ProjectID = $project->ID; |
127 | 127 | $environment->write(); |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * @param boolean $dryRun |
137 | 137 | */ |
138 | 138 | public function syncProjectPaths($paths, $dryRun = false) { |
139 | - foreach($paths as $path) { |
|
140 | - if(!DNProject::get()->filter('Name', $path)->count()) { |
|
139 | + foreach ($paths as $path) { |
|
140 | + if (!DNProject::get()->filter('Name', $path)->count()) { |
|
141 | 141 | $this->message($path); |
142 | - if(!$dryRun) { |
|
142 | + if (!$dryRun) { |
|
143 | 143 | DNProject::create_from_path($path)->write(); |
144 | 144 | } |
145 | 145 | } |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | * @param string $text |
151 | 151 | */ |
152 | 152 | protected function message($text) { |
153 | - if(PHP_SAPI !== 'cli') { |
|
154 | - $text = '<p>' . $text . '</p>' . PHP_EOL; |
|
153 | + if (PHP_SAPI !== 'cli') { |
|
154 | + $text = '<p>'.$text.'</p>'.PHP_EOL; |
|
155 | 155 | } |
156 | - echo ' - ' . $text . PHP_EOL; |
|
156 | + echo ' - '.$text.PHP_EOL; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @param string $text |
161 | 161 | */ |
162 | 162 | protected function echoHeader($text) { |
163 | - if(PHP_SAPI !== 'cli') { |
|
164 | - echo '<h2>' . $text . '</h2>' . PHP_EOL; |
|
163 | + if (PHP_SAPI !== 'cli') { |
|
164 | + echo '<h2>'.$text.'</h2>'.PHP_EOL; |
|
165 | 165 | } else { |
166 | - echo '# ' . $text . PHP_EOL; |
|
166 | + echo '# '.$text.PHP_EOL; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | ->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members) |
775 | 775 | ->setTitle('Who can upload?') |
776 | 776 | ->setDescription( |
777 | - 'Users who can upload archives linked to this environment into Deploynaut.<br />' . |
|
777 | + 'Users who can upload archives linked to this environment into Deploynaut.<br />'. |
|
778 | 778 | 'Linking them to an environment allows limiting download permissions (see below).' |
779 | 779 | ), |
780 | 780 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | // Add actions |
822 | 822 | $action = new FormAction('check', 'Check Connection'); |
823 | 823 | $action->setUseButtonTag(true); |
824 | - $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'; |
|
824 | + $dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'; |
|
825 | 825 | $action->setAttribute('data-url', $dataURL); |
826 | 826 | $fields->insertBefore($action, 'Name'); |
827 | 827 | |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | */ |
835 | 835 | public function onBeforeWrite() { |
836 | 836 | parent::onBeforeWrite(); |
837 | - if ($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
838 | - $this->Filename = $this->Name . '.rb'; |
|
837 | + if ($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
838 | + $this->Filename = $this->Name.'.rb'; |
|
839 | 839 | } |
840 | 840 | $this->checkEnvironmentPath(); |
841 | 841 | $this->writeConfigFile(); |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | if (!$this->Filename) { |
886 | 886 | return ''; |
887 | 887 | } |
888 | - return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
888 | + return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | && $this->Filename |
1040 | 1040 | && $this->CreateEnvConfig |
1041 | 1041 | ) { |
1042 | - $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
1042 | + $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
1043 | 1043 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
1044 | 1044 | } else if ($this->envFileExists() && $this->DeployConfig) { |
1045 | 1045 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | * @return string |
51 | 51 | */ |
52 | 52 | public function Name() { |
53 | - return (string)htmlentities($this->branch->getName()); |
|
53 | + return (string) htmlentities($this->branch->getName()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function Link() { |
57 | 57 | // Use a get-var for branch so that it can handle unsafe chars better |
58 | - return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name())); |
|
58 | + return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name())); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return string |
63 | 63 | */ |
64 | 64 | public function SHA() { |
65 | - return (string)htmlentities($this->branch->getCommit()->getHash()); |
|
65 | + return (string) htmlentities($this->branch->getCommit()->getHash()); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function LastUpdated() { |
80 | 80 | |
81 | - if($this->_lastUpdatedCache) { |
|
81 | + if ($this->_lastUpdatedCache) { |
|
82 | 82 | return $this->_lastUpdatedCache; |
83 | 83 | } |
84 | 84 | try { |
85 | 85 | $created = $this->branch->getCommit()->getCommitterDate(); |
86 | - } catch(Exception $e) { |
|
86 | + } catch (Exception $e) { |
|
87 | 87 | //occasionally parsing will fail this is a fallback to make it still work |
88 | 88 | return new SS_Datetime(); |
89 | 89 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | */ |
105 | 105 | public function IsOpenByDefault() { |
106 | - if($this->Name() == 'master') { |
|
106 | + if ($this->Name() == 'master') { |
|
107 | 107 | return " open"; |
108 | 108 | } else { |
109 | 109 | return ""; |
@@ -144,7 +144,7 @@ |
||
144 | 144 | $output['status_code'] = $statusCode; |
145 | 145 | $response = $this->getResponse(); |
146 | 146 | $response->addHeader('Content-Type', 'application/json'); |
147 | - $response->setBody(json_encode($output, JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK)); |
|
147 | + $response->setBody(json_encode($output, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK)); |
|
148 | 148 | $response->setStatusCode($statusCode); |
149 | 149 | return $response; |
150 | 150 | } |
@@ -263,12 +263,12 @@ |
||
263 | 263 | |
264 | 264 | // failover for older deployments |
265 | 265 | $started = $deployment->Created; |
266 | - if($deployment->DeployStarted) { |
|
266 | + if ($deployment->DeployStarted) { |
|
267 | 267 | $started = $deployment->DeployStarted; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $requested = $deployment->Created; |
271 | - if($deployment->DeployRequested) { |
|
271 | + if ($deployment->DeployRequested) { |
|
272 | 272 | $requested = $deployment->DeployRequested; |
273 | 273 | } |
274 | 274 |
@@ -66,11 +66,11 @@ |
||
66 | 66 | public function getModel($name = '') { |
67 | 67 | $base = Director::absoluteBaseURL(); |
68 | 68 | return [ |
69 | - 'basename' => Director::baseURL() . $this->getCurrentEnvironment()->Link('overview'), |
|
69 | + 'basename' => Director::baseURL().$this->getCurrentEnvironment()->Link('overview'), |
|
70 | 70 | 'dispatchers' => [ |
71 | - 'git' => $base . $this->getCurrentProject()->Link('git'), |
|
72 | - 'plan' => $base . $this->getCurrentEnvironment()->Link('plan'), |
|
73 | - 'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys') |
|
71 | + 'git' => $base.$this->getCurrentProject()->Link('git'), |
|
72 | + 'plan' => $base.$this->getCurrentEnvironment()->Link('plan'), |
|
73 | + 'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys') |
|
74 | 74 | ], |
75 | 75 | 'api_auth' => [ |
76 | 76 | 'name' => $this->getSecurityToken()->getName(), |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | public function LogLink() { |
111 | - return $this->Link() . '/log'; |
|
111 | + return $this->Link().'/log'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function canView($member = null) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return \Gitonomy\Git\Repository|null |
155 | 155 | */ |
156 | 156 | public function getRepository() { |
157 | - if(!$this->SHA) { |
|
157 | + if (!$this->SHA) { |
|
158 | 158 | return null; |
159 | 159 | } |
160 | 160 | return $this->Environment()->Project()->getRepository(); |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getCommit() { |
169 | 169 | $repo = $this->getRepository(); |
170 | - if($repo) { |
|
170 | + if ($repo) { |
|
171 | 171 | try { |
172 | 172 | return $this->Environment()->getCommit($this->SHA); |
173 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
173 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { |
|
174 | 174 | return null; |
175 | 175 | } |
176 | 176 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if (!$interface) { |
196 | 196 | return null; |
197 | 197 | } |
198 | - return $interface->CommitURL . '/' . $this->SHA; |
|
198 | + return $interface->CommitURL.'/'.$this->SHA; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function getCommitMessage() { |
207 | 207 | $commit = $this->getCommit(); |
208 | - if($commit) { |
|
208 | + if ($commit) { |
|
209 | 209 | try { |
210 | 210 | return Convert::raw2xml($this->Environment()->getCommitMessage($commit)); |
211 | - } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
211 | + } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { |
|
212 | 212 | return null; |
213 | 213 | } |
214 | 214 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $this->Environment()->getCommitTags($commit); |
226 | 226 | $returnTags = []; |
227 | 227 | if (!empty($tags)) { |
228 | - foreach($tags as $tag) { |
|
228 | + foreach ($tags as $tag) { |
|
229 | 229 | $field = Varchar::create('Tag', '255'); |
230 | 230 | $field->setValue($tag->getName()); |
231 | 231 | $returnTags[] = $field; |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getFullDeployMessages() { |
244 | 244 | $strategy = $this->getDeploymentStrategy(); |
245 | - if ($strategy->getActionCode()!=='full') return null; |
|
245 | + if ($strategy->getActionCode() !== 'full') return null; |
|
246 | 246 | |
247 | 247 | $changes = $strategy->getChangesModificationNeeded(); |
248 | 248 | $messages = []; |
249 | 249 | foreach ($changes as $change => $details) { |
250 | - if ($change==='Code version') continue; |
|
250 | + if ($change === 'Code version') continue; |
|
251 | 251 | |
252 | 252 | $messages[] = [ |
253 | 253 | 'Flag' => sprintf( |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function getTag() { |
277 | 277 | $tags = $this->getTags(); |
278 | - if($tags->count() > 0) { |
|
278 | + if ($tags->count() > 0) { |
|
279 | 279 | return $tags->last(); |
280 | 280 | } |
281 | 281 | return null; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | public function getChanges() { |
301 | 301 | $list = new ArrayList(); |
302 | 302 | $strategy = $this->getDeploymentStrategy(); |
303 | - foreach($strategy->getChanges() as $name => $change) { |
|
303 | + foreach ($strategy->getChanges() as $name => $change) { |
|
304 | 304 | $changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null; |
305 | 305 | $description = isset($change['description']) ? $change['description'] : ''; |
306 | 306 | $compareUrl = null; |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | // Make sure we use the SHA as it was written into this DNDeployment. |
351 | 351 | $args['sha'] = $this->SHA; |
352 | 352 | |
353 | - if(!$this->DeployerID) { |
|
353 | + if (!$this->DeployerID) { |
|
354 | 354 | $this->DeployerID = Member::currentUserID(); |
355 | 355 | } |
356 | 356 | |
357 | - if($this->DeployerID) { |
|
357 | + if ($this->DeployerID) { |
|
358 | 358 | $deployer = $this->Deployer(); |
359 | 359 | $message = sprintf( |
360 | 360 | 'Deploy to %s initiated by %s (%s), with IP address %s', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $cache = self::get_git_cache(); |
161 | 161 | // we only need to clear the tag cache since everything else is cached by SHA, that is for commit and |
162 | 162 | // commit message. |
163 | - $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_' . $this->ID]); |
|
163 | + $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_'.$this->ID]); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | return true; |
332 | 332 | } |
333 | 333 | |
334 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
334 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
335 | 335 | return $env->canRestore($member); |
336 | 336 | })->Count(); |
337 | 337 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return true; |
353 | 353 | } |
354 | 354 | |
355 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
355 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
356 | 356 | return $env->canBackup($member); |
357 | 357 | })->Count(); |
358 | 358 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | return true; |
374 | 374 | } |
375 | 375 | |
376 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
376 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
377 | 377 | return $env->canUploadArchive($member); |
378 | 378 | })->Count(); |
379 | 379 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | return true; |
395 | 395 | } |
396 | 396 | |
397 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
397 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
398 | 398 | return $env->canDownloadArchive($member); |
399 | 399 | })->Count(); |
400 | 400 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | // Key-pair is available, use it. |
454 | 454 | $processEnv = [ |
455 | 455 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
456 | - 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" |
|
456 | + 'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh" |
|
457 | 457 | ]; |
458 | 458 | } else { |
459 | 459 | $processEnv = []; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | $currentMember = self::$_current_member_cache; |
543 | 543 | return $this->Environments() |
544 | - ->filterByCallBack(function ($item) use ($currentMember) { |
|
544 | + ->filterByCallBack(function($item) use ($currentMember) { |
|
545 | 545 | return $item->canView($currentMember); |
546 | 546 | }); |
547 | 547 | } |
@@ -560,14 +560,14 @@ discard block |
||
560 | 560 | * @return false|DNDeployment |
561 | 561 | */ |
562 | 562 | public function currentBuilds() { |
563 | - if (!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { |
|
563 | + if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { |
|
564 | 564 | $currentBuilds = []; |
565 | 565 | foreach ($this->Environments() as $env) { |
566 | 566 | $currentBuilds[$env->Name] = $env->CurrentBuild(); |
567 | 567 | } |
568 | - self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; |
|
568 | + self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; |
|
569 | 569 | } |
570 | - return self::$relation_cache['currentBuilds.' . $this->ID]; |
|
570 | + return self::$relation_cache['currentBuilds.'.$this->ID]; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | */ |
809 | 809 | public function getPublicKeyPath() { |
810 | 810 | if ($privateKey = $this->getPrivateKeyPath()) { |
811 | - return $privateKey . '.pub'; |
|
811 | + return $privateKey.'.pub'; |
|
812 | 812 | } |
813 | 813 | return null; |
814 | 814 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | if (!empty($keyDir)) { |
824 | 824 | $filter = FileNameFilter::create(); |
825 | 825 | $name = $filter->filter($this->Name); |
826 | - return $keyDir . '/' . $name; |
|
826 | + return $keyDir.'/'.$name; |
|
827 | 827 | } |
828 | 828 | return null; |
829 | 829 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $filter = FileNameFilter::create(); |
843 | 843 | $name = $filter->filter($this->Name); |
844 | 844 | |
845 | - return $this->DNData()->getKeyDir() . '/' . $name; |
|
845 | + return $this->DNData()->getKeyDir().'/'.$name; |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | /* Look for each whitelisted hostname */ |
869 | 869 | foreach ($interfaces as $host => $interface) { |
870 | 870 | /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */ |
871 | - if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
871 | + if (preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
872 | 872 | |
873 | 873 | $path = $match[2]; |
874 | 874 | |
@@ -879,10 +879,10 @@ discard block |
||
879 | 879 | $components = explode('.', $host); |
880 | 880 | |
881 | 881 | foreach ($regex as $pattern => $replacement) { |
882 | - $path = preg_replace('/' . $pattern . '/', $replacement, $path); |
|
882 | + $path = preg_replace('/'.$pattern.'/', $replacement, $path); |
|
883 | 883 | } |
884 | 884 | |
885 | - $uxurl = Controller::join_links($scheme . '://', $host, $path); |
|
885 | + $uxurl = Controller::join_links($scheme.'://', $host, $path); |
|
886 | 886 | |
887 | 887 | if (array_key_exists('commit', $interface) && $interface['commit'] == false) { |
888 | 888 | $commiturl = false; |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | // {@see DataObject::extendedCan()} |
1010 | 1010 | $isDone = $this->extend('isProjectReady'); |
1011 | 1011 | if ($isDone && is_array($isDone)) { |
1012 | - $isDone = array_filter($isDone, function ($val) { |
|
1012 | + $isDone = array_filter($isDone, function($val) { |
|
1013 | 1013 | return !is_null($val); |
1014 | 1014 | }); |
1015 | 1015 | |
@@ -1094,11 +1094,11 @@ discard block |
||
1094 | 1094 | return false; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - $cachekey = $this->ID . '_commit_' . $sha; |
|
1097 | + $cachekey = $this->ID.'_commit_'.$sha; |
|
1098 | 1098 | $cache = self::get_git_cache(); |
1099 | 1099 | if (!($result = $cache->load($cachekey))) { |
1100 | 1100 | $result = $repo->getCommit($sha); |
1101 | - $cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_' . $this->ID]); |
|
1101 | + $cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_'.$this->ID]); |
|
1102 | 1102 | } |
1103 | 1103 | return $result; |
1104 | 1104 | } |
@@ -1108,11 +1108,11 @@ discard block |
||
1108 | 1108 | * @return string |
1109 | 1109 | */ |
1110 | 1110 | public function getCommitMessage(\Gitonomy\Git\Commit $commit) { |
1111 | - $cachekey = $this->ID . '_message_' . $commit->getRevision(); |
|
1111 | + $cachekey = $this->ID.'_message_'.$commit->getRevision(); |
|
1112 | 1112 | $cache = self::get_git_cache(); |
1113 | 1113 | if (!($result = $cache->load($cachekey))) { |
1114 | 1114 | $result = $commit->getMessage(); |
1115 | - $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_' . $this->ID]); |
|
1115 | + $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_'.$this->ID]); |
|
1116 | 1116 | } |
1117 | 1117 | return $result; |
1118 | 1118 | } |
@@ -1122,14 +1122,14 @@ discard block |
||
1122 | 1122 | * @return mixed |
1123 | 1123 | */ |
1124 | 1124 | public function getCommitTags(\Gitonomy\Git\Commit $commit) { |
1125 | - $cachekey = $this->ID . '_tags_' . $commit->getRevision(); |
|
1125 | + $cachekey = $this->ID.'_tags_'.$commit->getRevision(); |
|
1126 | 1126 | $cache = self::get_git_cache(); |
1127 | 1127 | $result = $cache->load($cachekey); |
1128 | 1128 | // we check against false, because in many cases the tag list is an empty array |
1129 | 1129 | if ($result === false) { |
1130 | 1130 | $repo = $this->getRepository(); |
1131 | 1131 | $result = $tags = $repo->getReferences()->resolveTags($commit->getRevision()); |
1132 | - $cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_' . $this->ID]); |
|
1132 | + $cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_'.$this->ID]); |
|
1133 | 1133 | } |
1134 | 1134 | return $result; |
1135 | 1135 | } |