@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | public function alarmHandler() { |
| 19 | 19 | $sigFile = $this->args['sigFile']; |
| 20 | 20 | if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) { |
| 21 | - $signal = (int)file_get_contents($sigFile); |
|
| 22 | - if (is_int($signal) && in_array((int)$signal, [ |
|
| 21 | + $signal = (int) file_get_contents($sigFile); |
|
| 22 | + if (is_int($signal) && in_array((int) $signal, [ |
|
| 23 | 23 | // The following signals are trapped by both Resque and Rainforest. |
| 24 | 24 | SIGTERM, |
| 25 | 25 | SIGINT, |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | SIGCONT |
| 31 | 31 | ])) { |
| 32 | 32 | echo sprintf( |
| 33 | - '[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL, |
|
| 33 | + '[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL, |
|
| 34 | 34 | $signal, |
| 35 | 35 | getmypid() |
| 36 | 36 | ); |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | // Dispatch to own process group. |
| 42 | 42 | $pgid = posix_getpgid(getmypid()); |
| 43 | - if ($pgid<=0) { |
|
| 43 | + if ($pgid <= 0) { |
|
| 44 | 44 | echo sprintf( |
| 45 | - '[-] Unable to send signal to invalid PGID "%s".' . PHP_EOL, |
|
| 45 | + '[-] Unable to send signal to invalid PGID "%s".'.PHP_EOL, |
|
| 46 | 46 | $pgid |
| 47 | 47 | ); |
| 48 | 48 | } else { |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | // to this job as a whole (including any subprocesses such as spawned by Symfony). |
| 61 | 61 | posix_setsid(); |
| 62 | 62 | |
| 63 | - if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) { |
|
| 63 | + if (function_exists('pcntl_alarm') && function_exists('pcntl_signal')) { |
|
| 64 | 64 | if (!empty($this->args['sigFile'])) { |
| 65 | - echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']); |
|
| 65 | + echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']); |
|
| 66 | 66 | declare(ticks = 1); |
| 67 | 67 | pcntl_signal(SIGALRM, [$this, 'alarmHandler']); |
| 68 | 68 | pcntl_alarm(1); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function perform() { |
| 77 | - echo "[-] DeployJob starting" . PHP_EOL; |
|
| 77 | + echo "[-] DeployJob starting".PHP_EOL; |
|
| 78 | 78 | $log = new DeploynautLogFile($this->args['logfile']); |
| 79 | 79 | |
| 80 | 80 | $deployment = DNDeployment::get()->byID($this->args['deploymentID']); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | // deploy onto a clean environment will not be performing any backup regardless of |
| 93 | 93 | // whether the predeploy_backup option was passed or not. |
| 94 | 94 | // Sometimes predeploy_backup comes through as string false from the frontend. |
| 95 | - if( |
|
| 95 | + if ( |
|
| 96 | 96 | !empty($this->args['predeploy_backup']) |
| 97 | 97 | && $this->args['predeploy_backup'] !== 'false' |
| 98 | 98 | && !empty($currentBuild) |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // Disallow concurrent deployments (don't rely on queuing implementation to restrict this) |
| 115 | 115 | // Only consider deployments started in the last 30 minutes (older jobs probably got stuck) |
| 116 | 116 | $runningDeployments = $environment->runningDeployments()->exclude('ID', $this->args['deploymentID']); |
| 117 | - if($runningDeployments->count()) { |
|
| 117 | + if ($runningDeployments->count()) { |
|
| 118 | 118 | $runningDeployment = $runningDeployments->first(); |
| 119 | 119 | $message = sprintf( |
| 120 | 120 | 'Error: another deployment is in progress (started at %s by %s)', |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | // all options from the DeploymentStrategy merged in, including sha. |
| 135 | 135 | $this->args |
| 136 | 136 | ); |
| 137 | - } catch(Exception $e) { |
|
| 137 | + } catch (Exception $e) { |
|
| 138 | 138 | // DeploynautJob will automatically trigger onFailure. |
| 139 | - echo "[-] DeployJob failed" . PHP_EOL; |
|
| 139 | + echo "[-] DeployJob failed".PHP_EOL; |
|
| 140 | 140 | throw $e; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $this->updateStatus(DNDeployment::TR_COMPLETE); |
| 144 | - echo "[-] DeployJob finished" . PHP_EOL; |
|
| 144 | + echo "[-] DeployJob finished".PHP_EOL; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function onFailure(Exception $exception) { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | DB::connect($databaseConfig); |
| 161 | 161 | $backupDataTransfer->Status = 'Finished'; |
| 162 | 162 | $backupDataTransfer->write(); |
| 163 | - } catch(Exception $e) { |
|
| 163 | + } catch (Exception $e) { |
|
| 164 | 164 | global $databaseConfig; |
| 165 | 165 | DB::connect($databaseConfig); |
| 166 | 166 | $backupDataTransfer->Status = 'Failed'; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return string |
| 46 | 46 | */ |
| 47 | 47 | public function getRawFilePath() { |
| 48 | - return $this->basePath . '/' . $this->logFile; |
|
| 48 | + return $this->basePath.'/'.$this->logFile; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | 55 | public function getSanitisedLogFilePath() { |
| 56 | - return $this->basePath . '/' . strtolower(FileNameFilter::create()->filter($this->logFile)); |
|
| 56 | + return $this->basePath.'/'.strtolower(FileNameFilter::create()->filter($this->logFile)); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // Make sure we write into the old path for existing logs. New logs use the sanitised file path instead. |
| 84 | 84 | $path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath(); |
| 85 | 85 | |
| 86 | - error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path); |
|
| 86 | + error_log('['.date('Y-m-d H:i:s').'] '.$message.PHP_EOL, 3, $path); |
|
| 87 | 87 | @chmod($path, 0666); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -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 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function Backend() { |
| 182 | 182 | $backends = array_keys($this->config()->get('allowed_backends', Config::FIRST_SET)); |
| 183 | - switch(sizeof($backends)) { |
|
| 183 | + switch (sizeof($backends)) { |
|
| 184 | 184 | // Nothing allowed, use the default value "DeploymentBackend" |
| 185 | 185 | case 0: |
| 186 | 186 | $backend = "DeploymentBackend"; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list |
| 195 | 195 | default: |
| 196 | 196 | $backend = $this->BackendIdentifier; |
| 197 | - if(!in_array($backend, $backends)) { |
|
| 197 | + if (!in_array($backend, $backends)) { |
|
| 198 | 198 | $backend = $backends[0]; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -256,14 +256,14 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | public function getBareURL() { |
| 258 | 258 | $url = parse_url($this->URL); |
| 259 | - if(isset($url['host'])) { |
|
| 259 | + if (isset($url['host'])) { |
|
| 260 | 260 | return strtolower($url['host']); |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | public function getBareDefaultURL() { |
| 265 | 265 | $url = parse_url($this->getDefaultURL()); |
| 266 | - if(isset($url['host'])) { |
|
| 266 | + if (isset($url['host'])) { |
|
| 267 | 267 | return strtolower($url['host']); |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -275,20 +275,20 @@ discard block |
||
| 275 | 275 | * @return boolean |
| 276 | 276 | */ |
| 277 | 277 | public function canView($member = null) { |
| 278 | - if(!$member) { |
|
| 278 | + if (!$member) { |
|
| 279 | 279 | $member = Member::currentUser(); |
| 280 | 280 | } |
| 281 | - if(!$member) { |
|
| 281 | + if (!$member) { |
|
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | 284 | // Must be logged in to check permissions |
| 285 | 285 | |
| 286 | - if(Permission::checkMember($member, 'ADMIN')) { |
|
| 286 | + if (Permission::checkMember($member, 'ADMIN')) { |
|
| 287 | 287 | return true; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions |
| 291 | - if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { |
|
| 291 | + if ($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { |
|
| 292 | 292 | return $this->Viewers()->byID($member->ID) |
| 293 | 293 | || $member->inGroups($this->ViewerGroups()); |
| 294 | 294 | } |
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | * @return boolean |
| 304 | 304 | */ |
| 305 | 305 | public function canDeploy($member = null) { |
| 306 | - if(!$member) { |
|
| 306 | + if (!$member) { |
|
| 307 | 307 | $member = Member::currentUser(); |
| 308 | 308 | } |
| 309 | - if(!$member) { |
|
| 309 | + if (!$member) { |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | // Must be logged in to check permissions |
@@ -338,10 +338,10 @@ discard block |
||
| 338 | 338 | * @return boolean true if $member can restore, and false if they can't. |
| 339 | 339 | */ |
| 340 | 340 | public function canRestore($member = null) { |
| 341 | - if(!$member) { |
|
| 341 | + if (!$member) { |
|
| 342 | 342 | $member = Member::currentUser(); |
| 343 | 343 | } |
| 344 | - if(!$member) { |
|
| 344 | + if (!$member) { |
|
| 345 | 345 | return false; |
| 346 | 346 | } |
| 347 | 347 | // Must be logged in to check permissions |
@@ -365,15 +365,15 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | public function canBackup($member = null) { |
| 367 | 367 | $project = $this->Project(); |
| 368 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 368 | + if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 369 | 369 | return false; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if(!$member) { |
|
| 372 | + if (!$member) { |
|
| 373 | 373 | $member = Member::currentUser(); |
| 374 | 374 | } |
| 375 | 375 | // Must be logged in to check permissions |
| 376 | - if(!$member) { |
|
| 376 | + if (!$member) { |
|
| 377 | 377 | return false; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | public function canUploadArchive($member = null) { |
| 402 | 402 | $project = $this->Project(); |
| 403 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 403 | + if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if(!$member) { |
|
| 407 | + if (!$member) { |
|
| 408 | 408 | $member = Member::currentUser(); |
| 409 | 409 | } |
| 410 | - if(!$member) { |
|
| 410 | + if (!$member) { |
|
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | // Must be logged in to check permissions |
@@ -430,10 +430,10 @@ discard block |
||
| 430 | 430 | * @return boolean true if $member can download archives from this environment, false if they can't. |
| 431 | 431 | */ |
| 432 | 432 | public function canDownloadArchive($member = null) { |
| 433 | - if(!$member) { |
|
| 433 | + if (!$member) { |
|
| 434 | 434 | $member = Member::currentUser(); |
| 435 | 435 | } |
| 436 | - if(!$member) { |
|
| 436 | + if (!$member) { |
|
| 437 | 437 | return false; |
| 438 | 438 | } |
| 439 | 439 | // Must be logged in to check permissions |
@@ -456,10 +456,10 @@ discard block |
||
| 456 | 456 | * @return boolean true if $member can delete archives from this environment, false if they can't. |
| 457 | 457 | */ |
| 458 | 458 | public function canDeleteArchive($member = null) { |
| 459 | - if(!$member) { |
|
| 459 | + if (!$member) { |
|
| 460 | 460 | $member = Member::currentUser(); |
| 461 | 461 | } |
| 462 | - if(!$member) { |
|
| 462 | + if (!$member) { |
|
| 463 | 463 | return false; |
| 464 | 464 | } |
| 465 | 465 | // Must be logged in to check permissions |
@@ -589,18 +589,18 @@ discard block |
||
| 589 | 589 | 'State' => 'Completed' |
| 590 | 590 | ))->sort('LastEdited DESC')->first(); |
| 591 | 591 | |
| 592 | - if(!$deploy || (!$deploy->SHA)) { |
|
| 592 | + if (!$deploy || (!$deploy->SHA)) { |
|
| 593 | 593 | return false; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | $repo = $this->Project()->getRepository(); |
| 597 | - if(!$repo) { |
|
| 597 | + if (!$repo) { |
|
| 598 | 598 | return $deploy; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | try { |
| 602 | 602 | $commit = $repo->getCommit($deploy->SHA); |
| 603 | - if($commit) { |
|
| 603 | + if ($commit) { |
|
| 604 | 604 | $deploy->Message = Convert::raw2xml($commit->getMessage()); |
| 605 | 605 | $deploy->Committer = Convert::raw2xml($commit->getCommitterName()); |
| 606 | 606 | $deploy->CommitDate = $commit->getCommitterDate()->Format('d/m/Y g:ia'); |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | $deploy->AuthorDate = $commit->getAuthorDate()->Format('d/m/Y g:ia'); |
| 609 | 609 | } |
| 610 | 610 | // We can't find this SHA, so we ignore adding a commit message to the deployment |
| 611 | - } catch(Exception $ex) { } |
|
| 611 | + } catch (Exception $ex) { } |
|
| 612 | 612 | |
| 613 | 613 | return $deploy; |
| 614 | 614 | } |
@@ -631,17 +631,17 @@ discard block |
||
| 631 | 631 | protected function getCommitData($sha) { |
| 632 | 632 | try { |
| 633 | 633 | $repo = $this->Project()->getRepository(); |
| 634 | - if($repo !== false) { |
|
| 634 | + if ($repo !== false) { |
|
| 635 | 635 | $commit = new \Gitonomy\Git\Commit($repo, $sha); |
| 636 | 636 | return [ |
| 637 | - 'AuthorName' => (string)Convert::raw2xml($commit->getAuthorName()), |
|
| 638 | - 'AuthorEmail' => (string)Convert::raw2xml($commit->getAuthorEmail()), |
|
| 639 | - 'Message' => (string)Convert::raw2xml($commit->getMessage()), |
|
| 637 | + 'AuthorName' => (string) Convert::raw2xml($commit->getAuthorName()), |
|
| 638 | + 'AuthorEmail' => (string) Convert::raw2xml($commit->getAuthorEmail()), |
|
| 639 | + 'Message' => (string) Convert::raw2xml($commit->getMessage()), |
|
| 640 | 640 | 'ShortHash' => Convert::raw2xml($commit->getFixedShortHash(8)), |
| 641 | 641 | 'Hash' => Convert::raw2xml($commit->getHash()) |
| 642 | 642 | ]; |
| 643 | 643 | } |
| 644 | - } catch(\Gitonomy\Git\Exception\ReferenceNotFoundException $exc) { |
|
| 644 | + } catch (\Gitonomy\Git\Exception\ReferenceNotFoundException $exc) { |
|
| 645 | 645 | SS_Log::log($exc, SS_Log::WARN); |
| 646 | 646 | } |
| 647 | 647 | return array( |
@@ -713,12 +713,12 @@ discard block |
||
| 713 | 713 | $fields = new FieldList(new TabSet('Root')); |
| 714 | 714 | |
| 715 | 715 | $project = $this->Project(); |
| 716 | - if($project && $project->exists()) { |
|
| 716 | + if ($project && $project->exists()) { |
|
| 717 | 717 | $viewerGroups = $project->Viewers(); |
| 718 | 718 | $groups = $viewerGroups->sort('Title')->map()->toArray(); |
| 719 | 719 | $members = array(); |
| 720 | - foreach($viewerGroups as $group) { |
|
| 721 | - foreach($group->Members()->map() as $k => $v) { |
|
| 720 | + foreach ($viewerGroups as $group) { |
|
| 721 | + foreach ($group->Members()->map() as $k => $v) { |
|
| 722 | 722 | $members[$k] = $v; |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | // Backend identifier - pick from a named list of configurations specified in YML config |
| 756 | 756 | $backends = $this->config()->get('allowed_backends', Config::FIRST_SET); |
| 757 | 757 | // If there's only 1 backend, then user selection isn't needed |
| 758 | - if(sizeof($backends) > 1) { |
|
| 758 | + if (sizeof($backends) > 1) { |
|
| 759 | 759 | $fields->addFieldToTab('Root.Main', DropdownField::create('BackendIdentifier', 'Deployment backend') |
| 760 | 760 | ->setSource($backends) |
| 761 | 761 | ->setDescription('What kind of deployment system should be used to deploy to this environment')); |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | ->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members) |
| 805 | 805 | ->setTitle('Who can upload?') |
| 806 | 806 | ->setDescription( |
| 807 | - 'Users who can upload archives linked to this environment into Deploynaut.<br />' . |
|
| 807 | + 'Users who can upload archives linked to this environment into Deploynaut.<br />'. |
|
| 808 | 808 | 'Linking them to an environment allows limiting download permissions (see below).' |
| 809 | 809 | ), |
| 810 | 810 | |
@@ -824,14 +824,14 @@ discard block |
||
| 824 | 824 | )); |
| 825 | 825 | |
| 826 | 826 | // The Main.DeployConfig |
| 827 | - if($this->Project()->exists()) { |
|
| 827 | + if ($this->Project()->exists()) { |
|
| 828 | 828 | $this->setDeployConfigurationFields($fields); |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | // The DataArchives |
| 832 | 832 | $dataArchiveConfig = GridFieldConfig_RecordViewer::create(); |
| 833 | 833 | $dataArchiveConfig->removeComponentsByType('GridFieldAddNewButton'); |
| 834 | - if(class_exists('GridFieldBulkManager')) { |
|
| 834 | + if (class_exists('GridFieldBulkManager')) { |
|
| 835 | 835 | $dataArchiveConfig->addComponent(new GridFieldBulkManager()); |
| 836 | 836 | } |
| 837 | 837 | $dataArchive = GridField::create('DataArchives', 'Data Archives', $this->DataArchives(), $dataArchiveConfig); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | // Deployments |
| 841 | 841 | $deploymentsConfig = GridFieldConfig_RecordEditor::create(); |
| 842 | 842 | $deploymentsConfig->removeComponentsByType('GridFieldAddNewButton'); |
| 843 | - if(class_exists('GridFieldBulkManager')) { |
|
| 843 | + if (class_exists('GridFieldBulkManager')) { |
|
| 844 | 844 | $deploymentsConfig->addComponent(new GridFieldBulkManager()); |
| 845 | 845 | } |
| 846 | 846 | $deployments = GridField::create('Deployments', 'Deployments', $this->Deployments(), $deploymentsConfig); |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | // Add actions |
| 852 | 852 | $action = new FormAction('check', 'Check Connection'); |
| 853 | 853 | $action->setUseButtonTag(true); |
| 854 | - $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'; |
|
| 854 | + $dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'; |
|
| 855 | 855 | $action->setAttribute('data-url', $dataURL); |
| 856 | 856 | $fields->insertBefore($action, 'Name'); |
| 857 | 857 | |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | * @param FieldList $fields |
| 865 | 865 | */ |
| 866 | 866 | protected function setDeployConfigurationFields(&$fields) { |
| 867 | - if(!$this->config()->get('allow_web_editing')) { |
|
| 867 | + if (!$this->config()->get('allow_web_editing')) { |
|
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if($this->envFileExists()) { |
|
| 871 | + if ($this->envFileExists()) { |
|
| 872 | 872 | $deployConfig = new TextareaField('DeployConfig', 'Deploy config', $this->getEnvironmentConfig()); |
| 873 | 873 | $deployConfig->setRows(40); |
| 874 | 874 | $fields->insertAfter($deployConfig, 'Filename'); |
@@ -888,8 +888,8 @@ discard block |
||
| 888 | 888 | */ |
| 889 | 889 | public function onBeforeWrite() { |
| 890 | 890 | parent::onBeforeWrite(); |
| 891 | - if($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
| 892 | - $this->Filename = $this->Name . '.rb'; |
|
| 891 | + if ($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
| 892 | + $this->Filename = $this->Name.'.rb'; |
|
| 893 | 893 | } |
| 894 | 894 | $this->checkEnvironmentPath(); |
| 895 | 895 | $this->writeConfigFile(); |
@@ -898,13 +898,13 @@ discard block |
||
| 898 | 898 | public function onAfterWrite() { |
| 899 | 899 | parent::onAfterWrite(); |
| 900 | 900 | |
| 901 | - if($this->Usage === self::PRODUCTION || $this->Usage === self::UAT) { |
|
| 901 | + if ($this->Usage === self::PRODUCTION || $this->Usage === self::UAT) { |
|
| 902 | 902 | $conflicting = DNEnvironment::get() |
| 903 | 903 | ->filter('ProjectID', $this->ProjectID) |
| 904 | 904 | ->filter('Usage', $this->Usage) |
| 905 | 905 | ->exclude('ID', $this->ID); |
| 906 | 906 | |
| 907 | - foreach($conflicting as $otherEnvironment) { |
|
| 907 | + foreach ($conflicting as $otherEnvironment) { |
|
| 908 | 908 | $otherEnvironment->Usage = self::UNSPECIFIED; |
| 909 | 909 | $otherEnvironment->write(); |
| 910 | 910 | } |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | protected function checkEnvironmentPath() { |
| 919 | 919 | // Create folder if it doesn't exist |
| 920 | 920 | $configDir = dirname($this->getConfigFilename()); |
| 921 | - if(!file_exists($configDir) && $configDir) { |
|
| 921 | + if (!file_exists($configDir) && $configDir) { |
|
| 922 | 922 | mkdir($configDir, 0777, true); |
| 923 | 923 | } |
| 924 | 924 | } |
@@ -927,18 +927,18 @@ discard block |
||
| 927 | 927 | * Write the deployment config file to filesystem |
| 928 | 928 | */ |
| 929 | 929 | protected function writeConfigFile() { |
| 930 | - if(!$this->config()->get('allow_web_editing')) { |
|
| 930 | + if (!$this->config()->get('allow_web_editing')) { |
|
| 931 | 931 | return; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | // Create a basic new environment config from a template |
| 935 | - if(!$this->envFileExists() |
|
| 935 | + if (!$this->envFileExists() |
|
| 936 | 936 | && $this->Filename |
| 937 | 937 | && $this->CreateEnvConfig |
| 938 | 938 | ) { |
| 939 | - $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
| 939 | + $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
| 940 | 940 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
| 941 | - } else if($this->envFileExists() && $this->DeployConfig) { |
|
| 941 | + } else if ($this->envFileExists() && $this->DeployConfig) { |
|
| 942 | 942 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
| 943 | 943 | } |
| 944 | 944 | } |
@@ -949,12 +949,12 @@ discard block |
||
| 949 | 949 | public function onAfterDelete() { |
| 950 | 950 | parent::onAfterDelete(); |
| 951 | 951 | // Create a basic new environment config from a template |
| 952 | - if($this->config()->get('allow_web_editing') && $this->envFileExists()) { |
|
| 952 | + if ($this->config()->get('allow_web_editing') && $this->envFileExists()) { |
|
| 953 | 953 | unlink($this->getConfigFilename()); |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | $create = $this->CreateEnvironment(); |
| 957 | - if($create && $create->exists()) { |
|
| 957 | + if ($create && $create->exists()) { |
|
| 958 | 958 | $create->delete(); |
| 959 | 959 | } |
| 960 | 960 | } |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | * @return string |
| 964 | 964 | */ |
| 965 | 965 | protected function getEnvironmentConfig() { |
| 966 | - if(!$this->envFileExists()) { |
|
| 966 | + if (!$this->envFileExists()) { |
|
| 967 | 967 | return ''; |
| 968 | 968 | } |
| 969 | 969 | return file_get_contents($this->getConfigFilename()); |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * @return boolean |
| 974 | 974 | */ |
| 975 | 975 | protected function envFileExists() { |
| 976 | - if(!$this->getConfigFilename()) { |
|
| 976 | + if (!$this->getConfigFilename()) { |
|
| 977 | 977 | return false; |
| 978 | 978 | } |
| 979 | 979 | return file_exists($this->getConfigFilename()); |
@@ -985,13 +985,13 @@ discard block |
||
| 985 | 985 | * @return string |
| 986 | 986 | */ |
| 987 | 987 | public function getConfigFilename() { |
| 988 | - if(!$this->Project()->exists()) { |
|
| 988 | + if (!$this->Project()->exists()) { |
|
| 989 | 989 | return ''; |
| 990 | 990 | } |
| 991 | - if(!$this->Filename) { |
|
| 991 | + if (!$this->Filename) { |
|
| 992 | 992 | return ''; |
| 993 | 993 | } |
| 994 | - return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
| 994 | + return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | /** |
@@ -1004,24 +1004,24 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | public static function array_to_viewabledata($array) { |
| 1006 | 1006 | // Don't transform non-arrays |
| 1007 | - if(!is_array($array)) { |
|
| 1007 | + if (!is_array($array)) { |
|
| 1008 | 1008 | return $array; |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | // Figure out whether this is indexed or associative |
| 1012 | 1012 | $keys = array_keys($array); |
| 1013 | 1013 | $assoc = ($keys != array_keys($keys)); |
| 1014 | - if($assoc) { |
|
| 1014 | + if ($assoc) { |
|
| 1015 | 1015 | // Treat as viewable data |
| 1016 | 1016 | $data = new ArrayData(array()); |
| 1017 | - foreach($array as $key => $value) { |
|
| 1017 | + foreach ($array as $key => $value) { |
|
| 1018 | 1018 | $data->setField($key, self::array_to_viewabledata($value)); |
| 1019 | 1019 | } |
| 1020 | 1020 | return $data; |
| 1021 | 1021 | } else { |
| 1022 | 1022 | // Treat this as basic non-associative list |
| 1023 | 1023 | $list = new ArrayList(); |
| 1024 | - foreach($array as $value) { |
|
| 1024 | + foreach ($array as $value) { |
|
| 1025 | 1025 | $list->push(self::array_to_viewabledata($value)); |
| 1026 | 1026 | } |
| 1027 | 1027 | return $list; |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | $result = parent::validate(); |
| 1033 | 1033 | $backend = $this->Backend(); |
| 1034 | 1034 | |
| 1035 | - if(strcasecmp('test', $this->Name) === 0 && get_class($backend) == 'CapistranoDeploymentBackend') { |
|
| 1035 | + if (strcasecmp('test', $this->Name) === 0 && get_class($backend) == 'CapistranoDeploymentBackend') { |
|
| 1036 | 1036 | $result->error('"test" is not a valid environment name when using Capistrano backend.'); |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -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 ""; |
@@ -109,7 +109,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -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 | } |