@@ -5,7 +5,7 @@ |
||
5 | 5 | |
6 | 6 | public function updateItemEditForm($form) |
7 | 7 | { |
8 | - if ($this->owner->record->hasMethod('Link')) { |
|
8 | + if($this->owner->record->hasMethod('Link')) { |
|
9 | 9 | $link = sprintf( |
10 | 10 | '<a style="margin: 0.5em" target="deploynaut-frontend" href="%s">Preview »</a>', |
11 | 11 | $this->owner->record->Link() |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function saveInto(DataObjectInterface $record) |
19 | 19 | { |
20 | - if (!isset($_FILES[$this->name])) { |
|
20 | + if(!isset($_FILES[$this->name])) { |
|
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | |
24 | - if (!($record instanceof DNDataArchive)) { |
|
24 | + if(!($record instanceof DNDataArchive)) { |
|
25 | 25 | throw new LogicException('Saving into wrong type, expected DNDataArchive'); |
26 | 26 | } |
27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | /** @var DNDataTransfer $dataTransfer */ |
31 | 31 | $dataTransfer = $dataArchive->DataTransfers()->First(); |
32 | - if (!$dataTransfer) { |
|
32 | + if(!$dataTransfer) { |
|
33 | 33 | throw new LogicException('No transfer found'); |
34 | 34 | } |
35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | $absolutePath = $dataArchive->generateFilepath($dataTransfer); |
41 | 41 | $relativePath = preg_replace('#^' . preg_quote(ASSETS_PATH) . '/#', '', $absolutePath); |
42 | 42 | $this->upload->loadIntoFile($_FILES[$this->name], $file, $relativePath); |
43 | - if ($this->upload->isError()) { |
|
43 | + if($this->upload->isError()) { |
|
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $file = $this->upload->getFile(); |
48 | - if ($this->relationAutoSetting) { |
|
48 | + if($this->relationAutoSetting) { |
|
49 | 49 | // save to record |
50 | 50 | $record->{$this->name . 'ID'} = $file->ID; |
51 | 51 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | $items = CompositeField::FieldList()->toArray(); |
12 | 12 | $fields = new ArrayList(); |
13 | 13 | |
14 | - foreach ($items as $item) { |
|
14 | + foreach($items as $item) { |
|
15 | 15 | $extra = array( |
16 | 16 | 'Selected' => $this->value == $item->getValue(), |
17 | 17 | ); |
@@ -36,13 +36,13 @@ |
||
36 | 36 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
37 | 37 | try { |
38 | 38 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
39 | - if (!($envCreate && $envCreate->exists())) { |
|
39 | + if(!($envCreate && $envCreate->exists())) { |
|
40 | 40 | throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID'])); |
41 | 41 | } |
42 | 42 | |
43 | 43 | // This will throw and exception if it fails. |
44 | 44 | $envCreate->createEnvironment(); |
45 | - } catch (Exception $e) { |
|
45 | + } catch(Exception $e) { |
|
46 | 46 | $this->updateStatus('Failed'); |
47 | 47 | echo "[-] CreateEnvJob failed" . PHP_EOL; |
48 | 48 | throw $e; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $environment = $dataTransfer->Environment(); |
36 | 36 | $backupDataTransfer = null; |
37 | 37 | |
38 | - if (!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') { |
|
38 | + if(!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') { |
|
39 | 39 | $backupDataTransfer = DNDataTransfer::create(); |
40 | 40 | $backupDataTransfer->EnvironmentID = $environment->ID; |
41 | 41 | $backupDataTransfer->Direction = 'get'; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | )) |
62 | 62 | ->exclude('ID', $dataTransfer->ID); |
63 | 63 | |
64 | - if ($runningTransfers->count()) { |
|
64 | + if($runningTransfers->count()) { |
|
65 | 65 | $runningTransfer = $runningTransfers->first(); |
66 | 66 | $log->write(sprintf( |
67 | 67 | '[-] Error: another transfer is in progress (started at %s by %s)', |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | |
79 | 79 | // before we push data to an environment, we'll make a backup first |
80 | - if ($backupDataTransfer) { |
|
80 | + if($backupDataTransfer) { |
|
81 | 81 | $log->write('Backing up existing data'); |
82 | 82 | $environment->Backend()->dataTransfer( |
83 | 83 | $backupDataTransfer, |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | $dataTransfer, |
90 | 90 | $log |
91 | 91 | ); |
92 | - } catch (RuntimeException $exc) { |
|
92 | + } catch(RuntimeException $exc) { |
|
93 | 93 | $log->write($exc->getMessage()); |
94 | 94 | |
95 | - if ($backupDataTransfer) { |
|
95 | + if($backupDataTransfer) { |
|
96 | 96 | $backupDataTransfer->Status = 'Failed'; |
97 | 97 | $backupDataTransfer->write(); |
98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | throw $exc; |
103 | 103 | } |
104 | 104 | |
105 | - if ($backupDataTransfer) { |
|
105 | + if($backupDataTransfer) { |
|
106 | 106 | $backupDataTransfer->Status = 'Finished'; |
107 | 107 | $backupDataTransfer->write(); |
108 | 108 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | )) |
42 | 42 | ->exclude('ID', $this->args['deploymentID']); |
43 | 43 | |
44 | - if ($runningDeployments->count()) { |
|
44 | + if($runningDeployments->count()) { |
|
45 | 45 | $runningDeployment = $runningDeployments->first(); |
46 | 46 | $log->write(sprintf( |
47 | 47 | '[-] Error: another deployment is in progress (started at %s by %s)', |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // all options from the DeploymentStrategy merged in, including sha. |
64 | 64 | $this->args |
65 | 65 | ); |
66 | - } catch (Exception $e) { |
|
66 | + } catch(Exception $e) { |
|
67 | 67 | $this->updateStatus('Failed'); |
68 | 68 | echo "[-] DeployJob failed" . PHP_EOL; |
69 | 69 | throw $e; |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | { |
43 | 43 | set_time_limit(0); |
44 | 44 | |
45 | - if (!empty($this->args['logfile'])) { |
|
45 | + if(!empty($this->args['logfile'])) { |
|
46 | 46 | $this->log = new DeploynautLogFile($this->args['logfile']); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $this->project = DNProject::get()->byId($this->args['projectID']); |
50 | - if (!($this->project && $this->project->exists())) { |
|
50 | + if(!($this->project && $this->project->exists())) { |
|
51 | 51 | throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID'])); |
52 | 52 | } |
53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | // Disallow concurrent git fetches on the same project. |
57 | 57 | // Only consider fetches started in the last 30 minutes (older jobs probably got stuck) |
58 | - if (!empty($this->args['fetchID'])) { |
|
58 | + if(!empty($this->args['fetchID'])) { |
|
59 | 59 | $runningFetches = DNGitFetch::get() |
60 | 60 | ->filter(array( |
61 | 61 | 'ProjectID' => $this->project->ID, |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | )) |
65 | 65 | ->exclude('ID', $this->args['fetchID']); |
66 | 66 | |
67 | - if ($runningFetches->count()) { |
|
67 | + if($runningFetches->count()) { |
|
68 | 68 | $runningFetch = $runningFetches->first(); |
69 | 69 | $message = sprintf( |
70 | 70 | 'Another fetch is in progress (started at %s by %s)', |
71 | 71 | $runningFetch->dbObject('Created')->Nice(), |
72 | 72 | $runningFetch->Deployer()->Title |
73 | 73 | ); |
74 | - if ($this->log) { |
|
74 | + if($this->log) { |
|
75 | 75 | $this->log->write($message); |
76 | 76 | } |
77 | 77 | throw new RuntimeException($message); |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | // Decide whether we need to just update what we already have |
82 | 82 | // or initiate a clone if no local repo exists. |
83 | 83 | try { |
84 | - if ($this->project->repoExists() && empty($this->args['forceClone'])) { |
|
84 | + if($this->project->repoExists() && empty($this->args['forceClone'])) { |
|
85 | 85 | $this->fetchRepo(); |
86 | 86 | } else { |
87 | 87 | $this->cloneRepo(); |
88 | 88 | } |
89 | - } catch (Exception $e) { |
|
89 | + } catch(Exception $e) { |
|
90 | 90 | $this->updateStatus('Failed'); |
91 | - if ($this->log) { |
|
91 | + if($this->log) { |
|
92 | 92 | $this->log->write($e->getMessage()); |
93 | 93 | } |
94 | 94 | throw $e; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | protected function cloneRepo() |
107 | 107 | { |
108 | - if (file_exists($this->project->getLocalCVSPath())) { |
|
108 | + if(file_exists($this->project->getLocalCVSPath())) { |
|
109 | 109 | $this->runCommand(sprintf( |
110 | 110 | 'rm -rf %s', |
111 | 111 | escapeshellarg($this->project->getLocalCVSPath()) |
@@ -128,17 +128,17 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function runCommand($command, $workingDir = null) |
130 | 130 | { |
131 | - if (!empty($this->user)) { |
|
131 | + if(!empty($this->user)) { |
|
132 | 132 | $command = sprintf('sudo -u %s %s', $this->user, $command); |
133 | 133 | } |
134 | - if ($this->log) { |
|
134 | + if($this->log) { |
|
135 | 135 | $this->log->write(sprintf('Running command: %s', $command)); |
136 | 136 | } |
137 | 137 | $process = new \Symfony\Component\Process\Process($command, $workingDir); |
138 | 138 | $process->setEnv($this->project->getProcessEnv()); |
139 | 139 | $process->setTimeout(1800); |
140 | 140 | $process->run(); |
141 | - if (!$process->isSuccessful()) { |
|
141 | + if(!$process->isSuccessful()) { |
|
142 | 142 | throw new RuntimeException($process->getErrorOutput()); |
143 | 143 | } |
144 | 144 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | global $databaseConfig; |
153 | 153 | DB::connect($databaseConfig); |
154 | 154 | |
155 | - if (!empty($this->args['fetchID'])) { |
|
155 | + if(!empty($this->args['fetchID'])) { |
|
156 | 156 | $fetch = DNGitFetch::get()->byID($this->args['fetchID']); |
157 | - if ($fetch && $fetch->exists()) { |
|
157 | + if($fetch && $fetch->exists()) { |
|
158 | 158 | $fetch->Status = $status; |
159 | 159 | $fetch->write(); |
160 | 160 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function LastUpdated() |
87 | 87 | { |
88 | - if ($this->_lastUpdatedCache) { |
|
88 | + if($this->_lastUpdatedCache) { |
|
89 | 89 | return $this->_lastUpdatedCache; |
90 | 90 | } |
91 | 91 | try { |
92 | 92 | $created = $this->branch->getCommit()->getCommitterDate(); |
93 | - } catch (Exception $e) { |
|
93 | + } catch(Exception $e) { |
|
94 | 94 | //occasionally parsing will fail this is a fallback to make it still work |
95 | 95 | return new SS_Datetime(); |
96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function IsOpenByDefault() |
113 | 113 | { |
114 | - if ($this->Name() == 'master') { |
|
114 | + if($this->Name() == 'master') { |
|
115 | 115 | return " open"; |
116 | 116 | } else { |
117 | 117 | return ""; |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | |
64 | 64 | try { |
65 | 65 | $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath()); |
66 | - } catch (Exception $e) { |
|
66 | + } catch(Exception $e) { |
|
67 | 67 | return $branches; |
68 | 68 | } |
69 | 69 | |
70 | - foreach ($repository->getReferences()->getBranches() as $branch) { |
|
70 | + foreach($repository->getReferences()->getBranches() as $branch) { |
|
71 | 71 | /** @var DNBranch $obj */ |
72 | 72 | $obj = DNBranch::create($branch, $this->project, $this->data); |
73 | - if ($branch->getName() == 'master') { |
|
73 | + if($branch->getName() == 'master') { |
|
74 | 74 | $firstBranch = array($branch->getName() => $obj); |
75 | 75 | } else { |
76 | 76 | $branches[$branch->getName()] = $obj; |
77 | 77 | } |
78 | 78 | } |
79 | - if ($firstBranch) { |
|
79 | + if($firstBranch) { |
|
80 | 80 | $branches = $firstBranch + $branches; |
81 | 81 | } |
82 | 82 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function byName($name) |
94 | 94 | { |
95 | - if ($this->loaded === false) { |
|
95 | + if($this->loaded === false) { |
|
96 | 96 | $this->getIterator(); |
97 | 97 | } |
98 | 98 | |
99 | - if (isset($this->items[$name])) { |
|
99 | + if(isset($this->items[$name])) { |
|
100 | 100 | return $this->items[$name]; |
101 | 101 | } |
102 | 102 | |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getIterator() |
113 | 113 | { |
114 | - if ($this->loaded === false) { |
|
114 | + if($this->loaded === false) { |
|
115 | 115 | $this->items = $this->getReferences(); |
116 | 116 | $this->loaded = true; |
117 | 117 | } |
118 | - foreach ($this->items as $i => $item) { |
|
119 | - if (is_array($item)) { |
|
118 | + foreach($this->items as $i => $item) { |
|
119 | + if(is_array($item)) { |
|
120 | 120 | $this->items[$i] = new ArrayData($item); |
121 | 121 | } |
122 | 122 | } |