@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | 76 | public function Name() { |
| 77 | - if($this->name == null) { |
|
| 77 | + if ($this->name == null) { |
|
| 78 | 78 | $this->name = $this->commit->getFixedShortHash(8); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | 96 | public function SubjectMessage() { |
| 97 | - if($this->subjectMessage == null) { |
|
| 97 | + if ($this->subjectMessage == null) { |
|
| 98 | 98 | $this->subjectMessage = $this->commit->getSubjectMessage(); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function BodyMessage() { |
| 105 | - if($this->bodyMessage == null) { |
|
| 105 | + if ($this->bodyMessage == null) { |
|
| 106 | 106 | $this->bodyMessage = $this->commit->getBodyMessage(); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | * @return ArrayList |
| 114 | 114 | */ |
| 115 | 115 | public function References() { |
| 116 | - if($this->references !== null) { |
|
| 116 | + if ($this->references !== null) { |
|
| 117 | 117 | return $this->references; |
| 118 | 118 | } |
| 119 | 119 | $this->references = new ArrayList(); |
| 120 | 120 | |
| 121 | 121 | // Add tags |
| 122 | - foreach($this->commit->resolveReferences() as $reference) { |
|
| 123 | - if($reference instanceof \Gitonomy\Git\Reference\Tag) { |
|
| 122 | + foreach ($this->commit->resolveReferences() as $reference) { |
|
| 123 | + if ($reference instanceof \Gitonomy\Git\Reference\Tag) { |
|
| 124 | 124 | $this->references->push(new ArrayData(array( |
| 125 | 125 | 'Name' => $reference->getName(), |
| 126 | 126 | 'Type' => 'Tag', |
@@ -151,16 +151,16 @@ discard block |
||
| 151 | 151 | public function CurrentlyDeployedTo() { |
| 152 | 152 | $environments = $this->project->Environments(); |
| 153 | 153 | $envList = new ArrayList(); |
| 154 | - foreach($environments as $environment) { |
|
| 154 | + foreach ($environments as $environment) { |
|
| 155 | 155 | $deployments = DNDeployment::get() |
| 156 | 156 | ->filter('State', 'Completed') |
| 157 | 157 | ->filter('EnvironmentID', $environment->ID) |
| 158 | 158 | ->sort('LastEdited DESC'); |
| 159 | - if(!$deployments->count()) { |
|
| 159 | + if (!$deployments->count()) { |
|
| 160 | 160 | continue; |
| 161 | 161 | } |
| 162 | 162 | $latest = $deployments->first(); |
| 163 | - if($latest->SHA === $this->commit->getHash()) { |
|
| 163 | + if ($latest->SHA === $this->commit->getHash()) { |
|
| 164 | 164 | $envList->push($environment); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function EverDeployedTo($environmentName) { |
| 175 | 175 | $environments = $this->project->Environments()->filter('Name', $environmentName); |
| 176 | - if(!$environments->count()) { |
|
| 176 | + if (!$environments->count()) { |
|
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | ->filter('State', 'Completed') |
| 184 | 184 | ->filter('EnvironmentID', $environment->ID); |
| 185 | 185 | |
| 186 | - if($deployments->count()) { |
|
| 186 | + if ($deployments->count()) { |
|
| 187 | 187 | return true; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -100,24 +100,24 @@ discard block |
||
| 100 | 100 | protected function getReferences() { |
| 101 | 101 | try { |
| 102 | 102 | $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath()); |
| 103 | - } catch(Exception $e) { |
|
| 103 | + } catch (Exception $e) { |
|
| 104 | 104 | return array(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if($this->getTags) { |
|
| 108 | - if($this->reference) { |
|
| 107 | + if ($this->getTags) { |
|
| 108 | + if ($this->reference) { |
|
| 109 | 109 | throw new LogicException("Can't have \$reference and \$getTags both set"); |
| 110 | 110 | } |
| 111 | 111 | $log = $repository->getReferences()->getTags(); |
| 112 | 112 | |
| 113 | - } else if($this->reference) { |
|
| 113 | + } else if ($this->reference) { |
|
| 114 | 114 | $log = $this->reference->getLog(); |
| 115 | 115 | } else { |
| 116 | 116 | $log = $repository->getLog(); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if($this->limit) { |
|
| 120 | - if(is_array($log)) { |
|
| 119 | + if ($this->limit) { |
|
| 120 | + if (is_array($log)) { |
|
| 121 | 121 | $limitedLog = array_slice($log, 0, $this->limit); |
| 122 | 122 | } else { |
| 123 | 123 | $limitedLog = $log->setLimit($this->limit); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // cache them for look up in byName |
| 130 | 130 | $builds = array(); |
| 131 | - foreach($limitedLog as $reference) { |
|
| 132 | - if(!empty($this->blockBranch)) { |
|
| 131 | + foreach ($limitedLog as $reference) { |
|
| 132 | + if (!empty($this->blockBranch)) { |
|
| 133 | 133 | $branchesIncluding = GitonomyCache::getIncludingBranches($reference); |
| 134 | - foreach($branchesIncluding as $candidate) { |
|
| 135 | - if($candidate->getName() == $this->blockBranch) { |
|
| 134 | + foreach ($branchesIncluding as $candidate) { |
|
| 135 | + if ($candidate->getName() == $this->blockBranch) { |
|
| 136 | 136 | // Break out of the function |
| 137 | 137 | return $builds; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if($this->getTags) { |
|
| 142 | + if ($this->getTags) { |
|
| 143 | 143 | $builds[] = DNTag::create($reference, $this->project, $this->data); |
| 144 | 144 | } else { |
| 145 | 145 | $name = $this->reference ? $this->reference->getName() : ''; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @return DNCommit |
| 158 | 158 | */ |
| 159 | 159 | public function byName($hash) { |
| 160 | - if($this->loaded === false) { |
|
| 160 | + if ($this->loaded === false) { |
|
| 161 | 161 | $this->items = $this->getReferences(); |
| 162 | 162 | $this->loaded = true; |
| 163 | 163 | } |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | // The item might not be in the list because of the limit, try to find |
| 166 | 166 | // in an older version and add it to the list. |
| 167 | 167 | $found = null; |
| 168 | - foreach($this->items as $item) { |
|
| 169 | - if($item->SHA() == $hash) { |
|
| 168 | + foreach ($this->items as $item) { |
|
| 169 | + if ($item->SHA() == $hash) { |
|
| 170 | 170 | $found = $item; |
| 171 | 171 | break; |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if($found === null) { |
|
| 175 | + if ($found === null) { |
|
| 176 | 176 | $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath()); |
| 177 | 177 | $commit = new Gitonomy\Git\Commit($repository, $hash); |
| 178 | 178 | $found = DNCommit::create($commit, $this->project, $this->data); |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @return ArrayIterator |
| 194 | 194 | */ |
| 195 | 195 | public function getIterator() { |
| 196 | - if($this->loaded === false) { |
|
| 196 | + if ($this->loaded === false) { |
|
| 197 | 197 | $this->items = $this->getReferences(); |
| 198 | 198 | $this->loaded = true; |
| 199 | 199 | } |
| 200 | - foreach($this->items as $item) { |
|
| 201 | - if(is_array($item)) { |
|
| 200 | + foreach ($this->items as $item) { |
|
| 201 | + if (is_array($item)) { |
|
| 202 | 202 | $this->items[] = new ArrayData($item); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function perform() { |
| 23 | - echo "[-] DataTransferJob starting" . PHP_EOL; |
|
| 23 | + echo "[-] DataTransferJob starting".PHP_EOL; |
|
| 24 | 24 | $log = new DeploynautLogFile($this->args['logfile']); |
| 25 | 25 | $dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']); |
| 26 | 26 | $environment = $dataTransfer->Environment(); |
| 27 | 27 | $backupDataTransfer = null; |
| 28 | 28 | |
| 29 | - if( |
|
| 29 | + if ( |
|
| 30 | 30 | !empty($this->args['backupBeforePush']) |
| 31 | 31 | && $this->args['backupBeforePush'] !== 'false' |
| 32 | 32 | && $dataTransfer->Direction == 'push' |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'Created:GreaterThan' => strtotime('-30 minutes') |
| 55 | 55 | )) |
| 56 | 56 | ->exclude('ID', $dataTransfer->ID); |
| 57 | - if($runningTransfers->count()) { |
|
| 57 | + if ($runningTransfers->count()) { |
|
| 58 | 58 | $runningTransfer = $runningTransfers->first(); |
| 59 | 59 | $message = sprintf( |
| 60 | 60 | 'Error: another transfer is in progress (started at %s by %s)', |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $this->performBackup($backupDataTransfer, $log); |
| 69 | 69 | $environment->Backend()->dataTransfer($dataTransfer, $log); |
| 70 | - } catch(Exception $e) { |
|
| 71 | - echo "[-] DataTransferJob failed" . PHP_EOL; |
|
| 70 | + } catch (Exception $e) { |
|
| 71 | + echo "[-] DataTransferJob failed".PHP_EOL; |
|
| 72 | 72 | throw $e; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->updateStatus('Finished'); |
| 76 | - echo "[-] DataTransferJob finished" . PHP_EOL; |
|
| 76 | + echo "[-] DataTransferJob finished".PHP_EOL; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | protected function performBackup($backupDataTransfer, DeploynautLogFile $log) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | DB::connect($databaseConfig); |
| 89 | 89 | $backupDataTransfer->Status = 'Finished'; |
| 90 | 90 | $backupDataTransfer->write(); |
| 91 | - } catch(Exception $e) { |
|
| 91 | + } catch (Exception $e) { |
|
| 92 | 92 | global $databaseConfig; |
| 93 | 93 | DB::connect($databaseConfig); |
| 94 | 94 | $backupDataTransfer->Status = 'Failed'; |
@@ -19,23 +19,23 @@ |
||
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | 21 | public function perform() { |
| 22 | - echo "[-] CreateEnvJob starting" . PHP_EOL; |
|
| 22 | + echo "[-] CreateEnvJob starting".PHP_EOL; |
|
| 23 | 23 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
| 24 | 24 | try { |
| 25 | 25 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
| 26 | - if(!($envCreate && $envCreate->exists())) { |
|
| 26 | + if (!($envCreate && $envCreate->exists())) { |
|
| 27 | 27 | throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID'])); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // This will throw and exception if it fails. |
| 31 | 31 | $envCreate->createEnvironment(); |
| 32 | 32 | |
| 33 | - } catch(Exception $e) { |
|
| 34 | - echo "[-] CreateEnvJob failed" . PHP_EOL; |
|
| 33 | + } catch (Exception $e) { |
|
| 34 | + echo "[-] CreateEnvJob failed".PHP_EOL; |
|
| 35 | 35 | throw $e; |
| 36 | 36 | } |
| 37 | 37 | $this->updateStatus('Finished'); |
| 38 | - echo "[-] CreateEnvJob finished" . PHP_EOL; |
|
| 38 | + echo "[-] CreateEnvJob finished".PHP_EOL; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | public function perform() { |
| 34 | 34 | set_time_limit(0); |
| 35 | 35 | |
| 36 | - if(!empty($this->args['logfile'])) { |
|
| 36 | + if (!empty($this->args['logfile'])) { |
|
| 37 | 37 | $this->log = new DeploynautLogFile($this->args['logfile']); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $this->project = DNProject::get()->byId($this->args['projectID']); |
| 41 | - if(!($this->project && $this->project->exists())) { |
|
| 41 | + if (!($this->project && $this->project->exists())) { |
|
| 42 | 42 | throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID'])); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // Disallow concurrent git fetches on the same project. |
| 48 | 48 | // Only consider fetches started in the last 30 minutes (older jobs probably got stuck) |
| 49 | 49 | try { |
| 50 | - if(!empty($this->args['fetchID'])) { |
|
| 50 | + if (!empty($this->args['fetchID'])) { |
|
| 51 | 51 | $runningFetches = DNGitFetch::get() |
| 52 | 52 | ->filter(array( |
| 53 | 53 | 'ProjectID' => $this->project->ID, |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | )) |
| 57 | 57 | ->exclude('ID', $this->args['fetchID']); |
| 58 | 58 | |
| 59 | - if($runningFetches->count()) { |
|
| 59 | + if ($runningFetches->count()) { |
|
| 60 | 60 | $runningFetch = $runningFetches->first(); |
| 61 | 61 | $message = sprintf( |
| 62 | 62 | 'Another fetch is in progress (started at %s by %s)', |
| 63 | 63 | $runningFetch->dbObject('Created')->Nice(), |
| 64 | 64 | $runningFetch->Deployer()->Title |
| 65 | 65 | ); |
| 66 | - if($this->log) { |
|
| 66 | + if ($this->log) { |
|
| 67 | 67 | $this->log->write($message); |
| 68 | 68 | } |
| 69 | 69 | throw new RuntimeException($message); |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // Decide whether we need to just update what we already have |
| 74 | 74 | // or initiate a clone if no local repo exists. |
| 75 | - if($this->project->repoExists() && empty($this->args['forceClone'])) { |
|
| 75 | + if ($this->project->repoExists() && empty($this->args['forceClone'])) { |
|
| 76 | 76 | $this->fetchRepo(); |
| 77 | 77 | } else { |
| 78 | 78 | $this->cloneRepo(); |
| 79 | 79 | } |
| 80 | - } catch(Exception $e) { |
|
| 81 | - if($this->log) { |
|
| 80 | + } catch (Exception $e) { |
|
| 81 | + if ($this->log) { |
|
| 82 | 82 | $this->log->write($e->getMessage()); |
| 83 | 83 | } |
| 84 | 84 | throw $e; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | protected function cloneRepo() { |
| 98 | - if(file_exists($this->project->getLocalCVSPath())) { |
|
| 98 | + if (file_exists($this->project->getLocalCVSPath())) { |
|
| 99 | 99 | $this->runCommand(sprintf( |
| 100 | 100 | 'rm -rf %s', |
| 101 | 101 | escapeshellarg($this->project->getLocalCVSPath()) |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | * @throws RuntimeException |
| 118 | 118 | */ |
| 119 | 119 | protected function runCommand($command, $workingDir = null) { |
| 120 | - if(!empty($this->user)) { |
|
| 120 | + if (!empty($this->user)) { |
|
| 121 | 121 | $command = sprintf('sudo -u %s %s', $this->user, $command); |
| 122 | 122 | } |
| 123 | - if($this->log) { |
|
| 123 | + if ($this->log) { |
|
| 124 | 124 | $this->log->write(sprintf('Running command: %s', $command)); |
| 125 | 125 | } |
| 126 | 126 | $process = new AbortableProcess($command, $workingDir); |
| 127 | 127 | $process->setEnv($this->project->getProcessEnv()); |
| 128 | 128 | $process->setTimeout(1800); |
| 129 | 129 | $process->run(); |
| 130 | - if(!$process->isSuccessful()) { |
|
| 130 | + if (!$process->isSuccessful()) { |
|
| 131 | 131 | throw new RuntimeException($process->getErrorOutput()); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | global $databaseConfig; |
| 141 | 141 | DB::connect($databaseConfig); |
| 142 | 142 | |
| 143 | - if(!empty($this->args['fetchID'])) { |
|
| 143 | + if (!empty($this->args['fetchID'])) { |
|
| 144 | 144 | $fetch = DNGitFetch::get()->byID($this->args['fetchID']); |
| 145 | - if($fetch && $fetch->exists()) { |
|
| 145 | + if ($fetch && $fetch->exists()) { |
|
| 146 | 146 | $fetch->Status = $status; |
| 147 | 147 | $fetch->write(); |
| 148 | 148 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | $items = CompositeField::FieldList()->toArray(); |
| 10 | 10 | $fields = new ArrayList(); |
| 11 | 11 | |
| 12 | - foreach($items as $item) { |
|
| 12 | + foreach ($items as $item) { |
|
| 13 | 13 | $extra = array( |
| 14 | 14 | 'Selected' => $this->value == $item->getValue(), |
| 15 | 15 | ); |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | * @return bool|DataArchiveFileField |
| 16 | 16 | */ |
| 17 | 17 | public function saveInto(DataObjectInterface $record) { |
| 18 | - if(!isset($_FILES[$this->name])) { |
|
| 18 | + if (!isset($_FILES[$this->name])) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if(!($record instanceof DNDataArchive)) { |
|
| 22 | + if (!($record instanceof DNDataArchive)) { |
|
| 23 | 23 | throw new LogicException('Saving into wrong type, expected DNDataArchive'); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | /** @var DNDataTransfer $dataTransfer */ |
| 29 | 29 | $dataTransfer = $dataArchive->DataTransfers()->First(); |
| 30 | - if(!$dataTransfer) { |
|
| 30 | + if (!$dataTransfer) { |
|
| 31 | 31 | throw new LogicException('No transfer found'); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | // Hack: loadIntoFile assumes paths relative to assets, |
| 37 | 37 | // otherwise it creates the whole structure *within* that folder |
| 38 | 38 | $absolutePath = $dataArchive->generateFilepath($dataTransfer); |
| 39 | - $relativePath = preg_replace('#^' . preg_quote(ASSETS_PATH) . '/#', '', $absolutePath); |
|
| 39 | + $relativePath = preg_replace('#^'.preg_quote(ASSETS_PATH).'/#', '', $absolutePath); |
|
| 40 | 40 | $this->upload->loadIntoFile($_FILES[$this->name], $file, $relativePath); |
| 41 | - if($this->upload->isError()) { |
|
| 41 | + if ($this->upload->isError()) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $file = $this->upload->getFile(); |
| 46 | - if($this->relationAutoSetting) { |
|
| 46 | + if ($this->relationAutoSetting) { |
|
| 47 | 47 | // save to record |
| 48 | - $record->{$this->name . 'ID'} = $file->ID; |
|
| 48 | + $record->{$this->name.'ID'} = $file->ID; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $this; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | // the 'ping' action is called via AJAX from the /admin and will cause |
| 7 | 7 | // the admin section to 'grow' over time. We only need the css and js |
| 8 | 8 | // for login, reset, logout and so on. |
| 9 | - if(!$this->owner->getRequest()->isAjax()) { |
|
| 9 | + if (!$this->owner->getRequest()->isAjax()) { |
|
| 10 | 10 | DNRoot::include_requirements(); |
| 11 | 11 | } |
| 12 | 12 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | $file = $this->owner; |
| 12 | 12 | $archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First(); |
| 13 | 13 | |
| 14 | - if($archive) { |
|
| 14 | + if ($archive) { |
|
| 15 | 15 | return $archive->canDownload($member); |
| 16 | 16 | } |
| 17 | 17 | |