Completed
Pull Request — master (#489)
by Helpful
03:51
created
code/api/DeploynautAPI.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
             'projects' => array(),
54 54
         );
55 55
 
56
-        if ($request->httpMethod() != 'GET') {
56
+        if($request->httpMethod() != 'GET') {
57 57
             return $this->message('API not found', 404);
58 58
         }
59 59
 
60
-        foreach (DNProject::get() as $item) {
61
-            if ($item->canView($this->getMember())) {
60
+        foreach(DNProject::get() as $item) {
61
+            if($item->canView($this->getMember())) {
62 62
                 $response['projects'][] = array(
63 63
                     "name" => $item->Name,
64 64
                     "href" => Director::absoluteURL($item->APILink("")),
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function project(SS_HTTPRequest $request)
79 79
     {
80 80
         $project = $this->getProject();
81
-        if (!$project) {
81
+        if(!$project) {
82 82
             return $this->project404Response();
83 83
         }
84 84
         return new APIProject($this, $project);
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
     public function environment(SS_HTTPRequest $request)
94 94
     {
95 95
         $project = $this->getProject();
96
-        if (!$project) {
96
+        if(!$project) {
97 97
             return $this->project404Response();
98 98
         }
99 99
 
100 100
         $environment = $this->getEnvironment();
101
-        if (!$environment) {
101
+        if(!$environment) {
102 102
             return $this->environment404Response();
103 103
         }
104 104
         return new APIEnvironment($this, $environment);
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
  * DeploynautAPI > APIProject > APIEnvironment
14 14
  *
15 15
  */
16
-class DeploynautAPI extends APINoun
17
-{
16
+class DeploynautAPI extends APINoun {
18 17
 
19 18
     /**
20 19
      * Default URL handlers - (Action)/(ID)//(OtherID)
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      * @param SS_HTTPRequest $request
47 46
      * @return SS_HTTPResponse
48 47
      */
49
-    public function listProjects(SS_HTTPRequest $request)
50
-    {
48
+    public function listProjects(SS_HTTPRequest $request) {
51 49
         $response = array(
52 50
             'href' => Director::absoluteURL($this->Link()),
53 51
             'projects' => array(),
@@ -75,8 +73,7 @@  discard block
 block discarded – undo
75 73
      * @param SS_HTTPRequest $request
76 74
      * @return APIProject
77 75
      */
78
-    public function project(SS_HTTPRequest $request)
79
-    {
76
+    public function project(SS_HTTPRequest $request) {
80 77
         $project = $this->getProject();
81 78
         if (!$project) {
82 79
             return $this->project404Response();
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      * @param SS_HTTPRequest $request
91 88
      * @return APIEnvironment
92 89
      */
93
-    public function environment(SS_HTTPRequest $request)
94
-    {
90
+    public function environment(SS_HTTPRequest $request) {
95 91
         $project = $this->getProject();
96 92
         if (!$project) {
97 93
             return $this->project404Response();
@@ -107,8 +103,7 @@  discard block
 block discarded – undo
107 103
     /**
108 104
      * @return SS_HTTPResponse
109 105
      */
110
-    protected function project404Response()
111
-    {
106
+    protected function project404Response() {
112 107
         $projectName = Convert::raw2xml($this->getRequest()->latestParam('Project'));
113 108
         return new SS_HTTPResponse('Project "' . $projectName . '" not found.', 404);
114 109
     }
@@ -116,8 +111,7 @@  discard block
 block discarded – undo
116 111
     /**
117 112
      * @return SS_HTTPResponse
118 113
      */
119
-    protected function environment404Response()
120
-    {
114
+    protected function environment404Response() {
121 115
         $envName = Convert::raw2xml($this->getRequest()->latestParam('Environment'));
122 116
         return new SS_HTTPResponse('Environment "' . $envName . '" not found.', 404);
123 117
     }
@@ -127,8 +121,7 @@  discard block
 block discarded – undo
127 121
      *
128 122
      * @return DNProject
129 123
      */
130
-    protected function getProject()
131
-    {
124
+    protected function getProject() {
132 125
         $projectName = $this->getRequest()->param('Project');
133 126
         return DNProject::get()->filter('Name', $projectName)->first();
134 127
     }
@@ -138,8 +131,7 @@  discard block
 block discarded – undo
138 131
      *
139 132
      * @return DNEnvironment
140 133
      */
141
-    protected function getEnvironment()
142
-    {
134
+    protected function getEnvironment() {
143 135
         $projectName = $this->getRequest()->param('Project');
144 136
         $project = DNProject::get()->filter('Name', $projectName)->first();
145 137
         $environmentName = $this->getRequest()->param('Environment');
@@ -149,8 +141,7 @@  discard block
 block discarded – undo
149 141
     /**
150 142
      * @return string
151 143
      */
152
-    public function Link()
153
-    {
144
+    public function Link() {
154 145
         return 'naut/api';
155 146
     }
156 147
 }
Please login to merge, or discard this patch.
code/api/nouns/APIEnvironment.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function index(SS_HTTPRequest $request)
19 19
     {
20
-        if (!$this->record->canView($this->getMember())) {
20
+        if(!$this->record->canView($this->getMember())) {
21 21
             return $this->message('You are not authorized to view this environment', 403);
22 22
         }
23
-        switch ($request->httpMethod()) {
23
+        switch($request->httpMethod()) {
24 24
             case 'GET':
25 25
                 $href = Director::absoluteURL($this->record->Project()->APILink($this->record->Name));
26 26
                 return $this->getAPIResponse(array(
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function ping(SS_HTTPRequest $request)
56 56
     {
57
-        if (!$this->record->canView($this->getMember())) {
57
+        if(!$this->record->canView($this->getMember())) {
58 58
             return $this->message('You are not authorized to do that on this environment', 403);
59 59
         }
60
-        switch ($request->httpMethod()) {
60
+        switch($request->httpMethod()) {
61 61
             case 'GET':
62 62
                 return $this->getPing($this->getRequest()->param('ID'));
63 63
             case 'POST':
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function deploy(SS_HTTPRequest $request)
75 75
     {
76
-        if (!$this->record->canView($this->getMember())) {
76
+        if(!$this->record->canView($this->getMember())) {
77 77
             return $this->message('You are not authorized to do that on this environment', 403);
78 78
         }
79
-        switch ($request->httpMethod()) {
79
+        switch($request->httpMethod()) {
80 80
             case 'GET':
81 81
                 return $this->getDeploy($this->getRequest()->param('ID'));
82 82
             case 'POST':
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function createPing()
113 113
     {
114
-        if (!$this->record->canDeploy($this->getMember())) {
114
+        if(!$this->record->canDeploy($this->getMember())) {
115 115
             return $this->message('You are not authorized to do that on this environment', 403);
116 116
         }
117 117
         $ping = DNPing::create();
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     protected function getPing($ID)
139 139
     {
140 140
         $ping = DNPing::get()->byID($ID);
141
-        if (!$ping) {
141
+        if(!$ping) {
142 142
             return $this->message('Ping not found', 404);
143 143
         }
144 144
         $output = array(
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
      */
155 155
     protected function createDeploy()
156 156
     {
157
-        if (!$this->record->canDeploy($this->getMember())) {
157
+        if(!$this->record->canDeploy($this->getMember())) {
158 158
             return $this->message('You are not authorized to do that on this environment', 403);
159 159
         }
160 160
 
161 161
         $reqBody = $this->getRequestBody();
162 162
 
163
-        if ($reqBody === null) {
163
+        if($reqBody === null) {
164 164
             return $this->message('the request body did not contain a valid JSON object.', 400);
165 165
         }
166 166
 
167
-        if (empty($reqBody['release'])) {
167
+        if(empty($reqBody['release'])) {
168 168
             return $this->message('deploy requires a {"release": "sha1"} in the body of the request.', 400);
169 169
         }
170 170
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     protected function getDeploy($id)
192 192
     {
193 193
         $deploy = DNDeployment::get()->byID($id);
194
-        if (!$deploy) {
194
+        if(!$deploy) {
195 195
             return $this->message('Deploy not found', 404);
196 196
         }
197 197
         $output = array(
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class APIEnvironment extends APINoun
4
-{
3
+class APIEnvironment extends APINoun {
5 4
 
6 5
     /**
7 6
      * @var array
@@ -15,8 +14,7 @@  discard block
 block discarded – undo
15 14
      * @param SS_HTTPRequest $request
16 15
      * @return SS_HTTPResponse
17 16
      */
18
-    public function index(SS_HTTPRequest $request)
19
-    {
17
+    public function index(SS_HTTPRequest $request) {
20 18
         if (!$this->record->canView($this->getMember())) {
21 19
             return $this->message('You are not authorized to view this environment', 403);
22 20
         }
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      * @param SS_HTTPRequest $request
53 51
      * @return SS_HTTPResponse
54 52
      */
55
-    public function ping(SS_HTTPRequest $request)
56
-    {
53
+    public function ping(SS_HTTPRequest $request) {
57 54
         if (!$this->record->canView($this->getMember())) {
58 55
             return $this->message('You are not authorized to do that on this environment', 403);
59 56
         }
@@ -71,8 +68,7 @@  discard block
 block discarded – undo
71 68
      * @param SS_HTTPRequest $request
72 69
      * @return SS_HTTPResponse
73 70
      */
74
-    public function deploy(SS_HTTPRequest $request)
75
-    {
71
+    public function deploy(SS_HTTPRequest $request) {
76 72
         if (!$this->record->canView($this->getMember())) {
77 73
             return $this->message('You are not authorized to do that on this environment', 403);
78 74
         }
@@ -89,8 +85,7 @@  discard block
 block discarded – undo
89 85
     /**
90 86
      * @return string
91 87
      */
92
-    public function Link()
93
-    {
88
+    public function Link() {
94 89
         return Controller::join_links(
95 90
             $this->parent->Link(),
96 91
             $this->record->Project()->Name,
@@ -101,16 +96,14 @@  discard block
 block discarded – undo
101 96
     /**
102 97
      * @return SS_HTTPResponse
103 98
      */
104
-    protected function showRecord()
105
-    {
99
+    protected function showRecord() {
106 100
         return $this->getAPIResponse($this->record->toMap());
107 101
     }
108 102
 
109 103
     /**
110 104
      * @return SS_HTTPResponse
111 105
      */
112
-    protected function createPing()
113
-    {
106
+    protected function createPing() {
114 107
         if (!$this->record->canDeploy($this->getMember())) {
115 108
             return $this->message('You are not authorized to do that on this environment', 403);
116 109
         }
@@ -135,8 +128,7 @@  discard block
 block discarded – undo
135 128
      * @param int $ID
136 129
      * @return SS_HTTPResponse
137 130
      */
138
-    protected function getPing($ID)
139
-    {
131
+    protected function getPing($ID) {
140 132
         $ping = DNPing::get()->byID($ID);
141 133
         if (!$ping) {
142 134
             return $this->message('Ping not found', 404);
@@ -152,8 +144,7 @@  discard block
 block discarded – undo
152 144
     /**
153 145
      * @return SS_HTTPResponse
154 146
      */
155
-    protected function createDeploy()
156
-    {
147
+    protected function createDeploy() {
157 148
         if (!$this->record->canDeploy($this->getMember())) {
158 149
             return $this->message('You are not authorized to do that on this environment', 403);
159 150
         }
@@ -188,8 +179,7 @@  discard block
 block discarded – undo
188 179
      * @param int $id
189 180
      * @return SS_HTTPResponse
190 181
      */
191
-    protected function getDeploy($id)
192
-    {
182
+    protected function getDeploy($id) {
193 183
         $deploy = DNDeployment::get()->byID($id);
194 184
         if (!$deploy) {
195 185
             return $this->message('Deploy not found', 404);
Please login to merge, or discard this patch.
code/api/nouns/APINoun.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     protected function getAPIResponse($output)
66 66
     {
67 67
         $response = $this->getResponse();
68
-        if ($this->respondWithText()) {
68
+        if($this->respondWithText()) {
69 69
             $body = print_r($output, true);
70 70
             $response->addHeader('Content-Type', 'text/plain');
71 71
         } else {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function respondWithJSON()
83 83
     {
84
-        if ($this->getRequest()->getExtension() == 'json') {
84
+        if($this->getRequest()->getExtension() == 'json') {
85 85
             return true;
86 86
         }
87
-        if (strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) {
87
+        if(strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) {
88 88
             return true;
89 89
         }
90 90
         return false;
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
      */
96 96
     protected function respondWithText()
97 97
     {
98
-        if ($this->getRequest()->getExtension() == 'txt') {
98
+        if($this->getRequest()->getExtension() == 'txt') {
99 99
             return true;
100 100
         }
101
-        if (strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) {
101
+        if(strpos($this->getRequest()->getHeader('Accept'), 'text/plain') !== false) {
102 102
             return true;
103 103
         }
104 104
         return false;
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Base class for the APINouns
4 4
  */
5
-class APINoun extends Controller
6
-{
5
+class APINoun extends Controller {
7 6
 
8 7
     /**
9 8
      * @var controller
@@ -26,8 +25,7 @@  discard block
 block discarded – undo
26 25
      * @param Controller|null $parent
27 26
      * @param DataObject|null $record
28 27
      */
29
-    public function __construct(\Controller $parent = null, DataObject $record = null)
30
-    {
28
+    public function __construct(\Controller $parent = null, DataObject $record = null) {
31 29
         $this->record = $record;
32 30
         $this->parent = $parent;
33 31
         parent::__construct();
@@ -36,8 +34,7 @@  discard block
 block discarded – undo
36 34
     /**
37 35
      * Enable basic auth on the API
38 36
      */
39
-    public function init()
40
-    {
37
+    public function init() {
41 38
         $this->member = BasicAuth::requireLogin('Deploynaut API');
42 39
         parent::init();
43 40
     }
@@ -45,16 +42,14 @@  discard block
 block discarded – undo
45 42
     /**
46 43
      * @return DataObject
47 44
      */
48
-    public function getRecord()
49
-    {
45
+    public function getRecord() {
50 46
         return $this->record;
51 47
     }
52 48
 
53 49
     /**
54 50
      * @return Member
55 51
      */
56
-    public function getMember()
57
-    {
52
+    public function getMember() {
58 53
         return $this->member;
59 54
     }
60 55
 
@@ -62,8 +57,7 @@  discard block
 block discarded – undo
62 57
      * @param array $output
63 58
      * @return SS_HTTPResponse
64 59
      */
65
-    protected function getAPIResponse($output)
66
-    {
60
+    protected function getAPIResponse($output) {
67 61
         $response = $this->getResponse();
68 62
         if ($this->respondWithText()) {
69 63
             $body = print_r($output, true);
@@ -79,8 +73,7 @@  discard block
 block discarded – undo
79 73
     /**
80 74
      * @return boolean
81 75
      */
82
-    protected function respondWithJSON()
83
-    {
76
+    protected function respondWithJSON() {
84 77
         if ($this->getRequest()->getExtension() == 'json') {
85 78
             return true;
86 79
         }
@@ -93,8 +86,7 @@  discard block
 block discarded – undo
93 86
     /**
94 87
      * @return boolean
95 88
      */
96
-    protected function respondWithText()
97
-    {
89
+    protected function respondWithText() {
98 90
         if ($this->getRequest()->getExtension() == 'txt') {
99 91
             return true;
100 92
         }
@@ -107,8 +99,7 @@  discard block
 block discarded – undo
107 99
     /**
108 100
      * @return array|null
109 101
      */
110
-    protected function getRequestBody()
111
-    {
102
+    protected function getRequestBody() {
112 103
         return Convert::json2array($this->getRequest()->getBody());
113 104
     }
114 105
 
@@ -119,8 +110,7 @@  discard block
 block discarded – undo
119 110
      * @param int $statusCode
120 111
      * @return SS_HTTPResponse
121 112
      */
122
-    protected function message($message, $statusCode)
123
-    {
113
+    protected function message($message, $statusCode) {
124 114
         $response = $this->getAPIResponse(array(
125 115
             'message' => $message,
126 116
             'statusCode' => $statusCode
Please login to merge, or discard this patch.
code/api/nouns/APIProject.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function index(SS_HTTPRequest $request)
19 19
     {
20
-        if (!$this->record->canView($this->getMember())) {
20
+        if(!$this->record->canView($this->getMember())) {
21 21
             return $this->message('You are not authorized to this environment', 403);
22 22
         }
23 23
 
24
-        switch ($request->httpMethod()) {
24
+        switch($request->httpMethod()) {
25 25
             case 'GET':
26 26
                 $response = array(
27 27
                     "name" => $this->record->Name,
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
                     "disk-quota-mb" => $this->record->DiskQuotaMB,
32 32
                     "environments" => array(),
33 33
                 );
34
-                foreach ($this->record->DNEnvironmentList() as $environment) {
34
+                foreach($this->record->DNEnvironmentList() as $environment) {
35 35
                     $response['environments'][] = array(
36 36
                         'name' => $environment->Name,
37 37
                         'href' => Director::absoluteURL($this->record->APILink($environment->Name)),
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function fetch(SS_HTTPRequest $request)
52 52
     {
53
-        if (!$this->record->canView($this->getMember())) {
53
+        if(!$this->record->canView($this->getMember())) {
54 54
             return $this->message('You are not authorized to do that on this environment', 403);
55 55
         }
56
-        switch ($request->httpMethod()) {
56
+        switch($request->httpMethod()) {
57 57
             case 'GET':
58 58
                 return $this->getFetch($this->getRequest()->param('ID'));
59 59
             case 'POST':
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     protected function getFetch($ID)
71 71
     {
72 72
         $ping = DNGitFetch::get()->byID($ID);
73
-        if (!$ping) {
73
+        if(!$ping) {
74 74
             return $this->message('Fetch not found', 404);
75 75
         }
76 76
         $output = array(
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class APIProject extends APINoun
4
-{
3
+class APIProject extends APINoun {
5 4
 
6 5
     /**
7 6
      * @var array
@@ -15,8 +14,7 @@  discard block
 block discarded – undo
15 14
      * @param SS_HTTPRequest $request
16 15
      * @return SS_HTTPResponse
17 16
      */
18
-    public function index(SS_HTTPRequest $request)
19
-    {
17
+    public function index(SS_HTTPRequest $request) {
20 18
         if (!$this->record->canView($this->getMember())) {
21 19
             return $this->message('You are not authorized to this environment', 403);
22 20
         }
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
      * @param SS_HTTPRequest $request
49 47
      * @return SS_HTTPResponse
50 48
      */
51
-    public function fetch(SS_HTTPRequest $request)
52
-    {
49
+    public function fetch(SS_HTTPRequest $request) {
53 50
         if (!$this->record->canView($this->getMember())) {
54 51
             return $this->message('You are not authorized to do that on this environment', 403);
55 52
         }
@@ -67,8 +64,7 @@  discard block
 block discarded – undo
67 64
      * @param int $ID
68 65
      * @return SS_HTTPResponse
69 66
      */
70
-    protected function getFetch($ID)
71
-    {
67
+    protected function getFetch($ID) {
72 68
         $ping = DNGitFetch::get()->byID($ID);
73 69
         if (!$ping) {
74 70
             return $this->message('Fetch not found', 404);
@@ -84,8 +80,7 @@  discard block
 block discarded – undo
84 80
     /**
85 81
      * @return SS_HTTPResponse
86 82
      */
87
-    protected function createFetch()
88
-    {
83
+    protected function createFetch() {
89 84
         /** @var DNGitFetch $fetch */
90 85
         $fetch = DNGitFetch::create();
91 86
         $fetch->ProjectID = $this->record->ID;
@@ -107,8 +102,7 @@  discard block
 block discarded – undo
107 102
     /**
108 103
      * @return string
109 104
      */
110
-    public function Link()
111
-    {
105
+    public function Link() {
112 106
         return Controller::join_links(
113 107
             $this->parent->Link(),
114 108
             $this->record->Name
Please login to merge, or discard this patch.
code/backends/CapistranoDeploymentBackend.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         $currentBuild = $environment->CurrentBuild();
32 32
         $currentSha = $currentBuild ? $currentBuild->SHA : '-';
33
-        if ($currentSha !== $options['sha']) {
33
+        if($currentSha !== $options['sha']) {
34 34
             $strategy->setChange('Code version', $currentSha, $options['sha']);
35 35
         }
36 36
         $strategy->setActionTitle('Confirm deployment');
@@ -71,53 +71,53 @@  discard block
 block discarded – undo
71 71
 
72 72
         // Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour
73 73
         // if build_filename isn't specified
74
-        if ($this->packageGenerator) {
74
+        if($this->packageGenerator) {
75 75
             $log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator)));
76 76
 
77 77
             try {
78 78
                 $args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log);
79
-            } catch (Exception $e) {
79
+            } catch(Exception $e) {
80 80
                 $log->write($e->getMessage());
81 81
                 throw $e;
82 82
             }
83 83
 
84
-            if (empty($args['build_filename'])) {
84
+            if(empty($args['build_filename'])) {
85 85
                 throw new RuntimeException('Failed to generate package.');
86 86
             }
87 87
         }
88 88
 
89 89
         $command = $this->getCommand('deploy', 'web', $environment, $args, $log);
90
-        $command->run(function ($type, $buffer) use ($log) {
90
+        $command->run(function($type, $buffer) use ($log) {
91 91
             $log->write($buffer);
92 92
         });
93 93
 
94 94
         // Deployment cleanup. We assume it is always safe to run this at the end, regardless of the outcome.
95 95
         $self = $this;
96
-        $cleanupFn = function () use ($self, $environment, $args, $log) {
96
+        $cleanupFn = function() use ($self, $environment, $args, $log) {
97 97
             $command = $self->getCommand('deploy:cleanup', 'web', $environment, $args, $log);
98
-            $command->run(function ($type, $buffer) use ($log) {
98
+            $command->run(function($type, $buffer) use ($log) {
99 99
                 $log->write($buffer);
100 100
             });
101 101
 
102
-            if (!$command->isSuccessful()) {
102
+            if(!$command->isSuccessful()) {
103 103
                 $this->extend('cleanupFailure', $environment, $sha, $log, $project);
104 104
                 $log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.');
105 105
             }
106 106
         };
107 107
 
108 108
         // Once the deployment has run it's necessary to update the maintenance page status
109
-        if (!empty($options['leaveMaintenancePage'])) {
109
+        if(!empty($options['leaveMaintenancePage'])) {
110 110
             $this->enableMaintenance($environment, $log, $project);
111 111
         }
112 112
 
113
-        if (!$command->isSuccessful()) {
113
+        if(!$command->isSuccessful()) {
114 114
             $cleanupFn();
115 115
             $this->extend('deployFailure', $environment, $sha, $log, $project);
116 116
             throw new RuntimeException($command->getErrorOutput());
117 117
         }
118 118
 
119 119
         // Check if maintenance page should be removed
120
-        if (empty($options['leaveMaintenancePage'])) {
120
+        if(empty($options['leaveMaintenancePage'])) {
121 121
             $this->disableMaintenance($environment, $log, $project);
122 122
         }
123 123
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $name = $environment->getFullName();
137 137
         $command = $this->getCommand('maintenance:enable', 'web', $environment, null, $log);
138
-        $command->run(function ($type, $buffer) use ($log) {
138
+        $command->run(function($type, $buffer) use ($log) {
139 139
             $log->write($buffer);
140 140
         });
141
-        if (!$command->isSuccessful()) {
141
+        if(!$command->isSuccessful()) {
142 142
             $this->extend('maintenanceEnableFailure', $environment, $log);
143 143
             throw new RuntimeException($command->getErrorOutput());
144 144
         }
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
     {
153 153
         $name = $environment->getFullName();
154 154
         $command = $this->getCommand('maintenance:disable', 'web', $environment, null, $log);
155
-        $command->run(function ($type, $buffer) use ($log) {
155
+        $command->run(function($type, $buffer) use ($log) {
156 156
             $log->write($buffer);
157 157
         });
158
-        if (!$command->isSuccessful()) {
158
+        if(!$command->isSuccessful()) {
159 159
             $this->extend('maintenanceDisableFailure', $environment, $log);
160 160
             throw new RuntimeException($command->getErrorOutput());
161 161
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
169 169
     {
170 170
         $command = $this->getCommand('deploy:check', 'web', $environment, null, $log);
171
-        $command->run(function ($type, $buffer) use ($log) {
171
+        $command->run(function($type, $buffer) use ($log) {
172 172
             $log->write($buffer);
173 173
             echo $buffer;
174 174
         });
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log)
181 181
     {
182
-        if ($dataTransfer->Direction == 'get') {
182
+        if($dataTransfer->Direction == 'get') {
183 183
             $this->dataTransferBackup($dataTransfer, $log);
184 184
         } else {
185 185
             $environment = $dataTransfer->Environment();
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
             // extract the sspak contents, we'll need these so capistrano can restore that content
191 191
             try {
192 192
                 $archive->extractArchive($workingDir);
193
-            } catch (Exception $e) {
193
+            } catch(Exception $e) {
194 194
                 $log->write($e->getMessage());
195 195
                 throw new RuntimeException($e->getMessage());
196 196
             }
197 197
 
198 198
             // validate the contents match the requested transfer mode
199 199
             $result = $archive->validateArchiveContents($dataTransfer->Mode);
200
-            if (!$result->valid()) {
200
+            if(!$result->valid()) {
201 201
                 // do some cleaning, get rid of the extracted archive lying around
202 202
                 $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir)));
203 203
                 $process->run();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $name = $environment->getFullName();
228 228
         $env = $environment->Project()->getProcessEnv();
229 229
 
230
-        if (!$args) {
230
+        if(!$args) {
231 231
             $args = array();
232 232
         }
233 233
         $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/');
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
         // Inject env string directly into the command.
236 236
         // Capistrano doesn't like the $process->setEnv($env) we'd normally do below.
237 237
         $envString = '';
238
-        if (!empty($env)) {
238
+        if(!empty($env)) {
239 239
             $envString .= 'env ';
240
-            foreach ($env as $key => $value) {
240
+            foreach($env as $key => $value) {
241 241
                 $envString .= "$key=\"$value\" ";
242 242
             }
243 243
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             $capTemplate
252 252
         );
253 253
 
254
-        if (defined('DEPLOYNAUT_CAPFILE')) {
254
+        if(defined('DEPLOYNAUT_CAPFILE')) {
255 255
             $capFile = DEPLOYNAUT_CAPFILE;
256 256
         } else {
257 257
             $capFile = ASSETS_PATH . '/Capfile';
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         file_put_contents($capFile, $cap);
260 260
 
261 261
         $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles";
262
-        foreach ($args as $argName => $argVal) {
262
+        foreach($args as $argName => $argVal) {
263 263
             $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal);
264 264
         }
265 265
 
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
         $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql';
299 299
 
300 300
         // Backup database
301
-        if (in_array($dataTransfer->Mode, array('all', 'db'))) {
301
+        if(in_array($dataTransfer->Mode, array('all', 'db'))) {
302 302
             $log->write(sprintf('Backup of database from "%s" started', $name));
303 303
             $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log);
304
-            $command->run(function ($type, $buffer) use ($log) {
304
+            $command->run(function($type, $buffer) use ($log) {
305 305
                 $log->write($buffer);
306 306
             });
307
-            if (!$command->isSuccessful()) {
307
+            if(!$command->isSuccessful()) {
308 308
                 $this->extend('dataTransferFailure', $environment, $log);
309 309
                 throw new RuntimeException($command->getErrorOutput());
310 310
             }
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
         }
313 313
 
314 314
         // Backup assets
315
-        if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
315
+        if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
316 316
             $log->write(sprintf('Backup of assets from "%s" started', $name));
317 317
             $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log);
318
-            $command->run(function ($type, $buffer) use ($log) {
318
+            $command->run(function($type, $buffer) use ($log) {
319 319
                 $log->write($buffer);
320 320
             });
321
-            if (!$command->isSuccessful()) {
321
+            if(!$command->isSuccessful()) {
322 322
                 $this->extend('dataTransferFailure', $environment, $log);
323 323
                 throw new RuntimeException($command->getErrorOutput());
324 324
             }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         try {
332 332
             $dataArchive->attachFile($sspakFilepath, $dataTransfer);
333 333
             $dataArchive->setArchiveFromFiles($filepathBase);
334
-        } catch (Exception $e) {
334
+        } catch(Exception $e) {
335 335
             $log->write($e->getMessage());
336 336
             throw new RuntimeException($e->getMessage());
337 337
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         // e.g. when just an assets backup has been requested and no database.sql exists.
342 342
         $process = new Process(sprintf('rm -rf %s/assets && rm -f %s', $filepathBase, $databasePath));
343 343
         $process->run();
344
-        if (!$process->isSuccessful()) {
344
+        if(!$process->isSuccessful()) {
345 345
             $log->write('Could not delete temporary files');
346 346
             throw new RuntimeException($process->getErrorOutput());
347 347
         }
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
     {
359 359
         $name = $environment->getFullName();
360 360
         $command = $this->getCommand('deploy:migrate', 'web', $environment, null, $log);
361
-        $command->run(function ($type, $buffer) use ($log) {
361
+        $command->run(function($type, $buffer) use ($log) {
362 362
             $log->write($buffer);
363 363
         });
364
-        if (!$command->isSuccessful()) {
364
+        if(!$command->isSuccessful()) {
365 365
             $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput()));
366 366
             throw new RuntimeException($command->getErrorOutput());
367 367
         }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
         // Rollback cleanup.
385 385
         $self = $this;
386
-        $cleanupFn = function () use ($self, $workingDir, $environment, $log) {
386
+        $cleanupFn = function() use ($self, $workingDir, $environment, $log) {
387 387
             // Rebuild makes sense even if failed - maybe we can at least partly recover.
388 388
             $self->rebuild($environment, $log);
389 389
             $process = new Process(sprintf('rm -rf %s', escapeshellarg($workingDir)));
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
         };
392 392
 
393 393
         // Restore database into target environment
394
-        if (in_array($dataTransfer->Mode, array('all', 'db'))) {
394
+        if(in_array($dataTransfer->Mode, array('all', 'db'))) {
395 395
             $log->write(sprintf('Restore of database to "%s" started', $name));
396 396
             $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql');
397 397
             $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log);
398
-            $command->run(function ($type, $buffer) use ($log) {
398
+            $command->run(function($type, $buffer) use ($log) {
399 399
                 $log->write($buffer);
400 400
             });
401
-            if (!$command->isSuccessful()) {
401
+            if(!$command->isSuccessful()) {
402 402
                 $cleanupFn();
403 403
                 $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput()));
404 404
                 $this->extend('dataTransferFailure', $environment, $log);
@@ -408,14 +408,14 @@  discard block
 block discarded – undo
408 408
         }
409 409
 
410 410
         // Restore assets into target environment
411
-        if (in_array($dataTransfer->Mode, array('all', 'assets'))) {
411
+        if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
412 412
             $log->write(sprintf('Restore of assets to "%s" started', $name));
413 413
             $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets');
414 414
             $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log);
415
-            $command->run(function ($type, $buffer) use ($log) {
415
+            $command->run(function($type, $buffer) use ($log) {
416 416
                 $log->write($buffer);
417 417
             });
418
-            if (!$command->isSuccessful()) {
418
+            if(!$command->isSuccessful()) {
419 419
                 $cleanupFn();
420 420
                 $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput()));
421 421
                 $this->extend('dataTransferFailure', $environment, $log);
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,18 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use \Symfony\Component\Process\Process;
3 3
 
4
-class CapistranoDeploymentBackend extends Object implements DeploymentBackend
5
-{
4
+class CapistranoDeploymentBackend extends Object implements DeploymentBackend {
6 5
 
7 6
     protected $packageGenerator;
8 7
 
9
-    public function getPackageGenerator()
10
-    {
8
+    public function getPackageGenerator() {
11 9
         return $this->packageGenerator;
12 10
     }
13 11
 
14
-    public function setPackageGenerator(PackageGenerator $packageGenerator)
15
-    {
12
+    public function setPackageGenerator(PackageGenerator $packageGenerator) {
16 13
         $this->packageGenerator = $packageGenerator;
17 14
     }
18 15
 
@@ -24,8 +21,7 @@  discard block
 block discarded – undo
24 21
      *
25 22
      * @return DeploymentStrategy
26 23
      */
27
-    public function planDeploy(DNEnvironment $environment, $options)
28
-    {
24
+    public function planDeploy(DNEnvironment $environment, $options) {
29 25
         $strategy = new DeploymentStrategy($environment, $options);
30 26
 
31 27
         $currentBuild = $environment->CurrentBuild();
@@ -131,8 +127,7 @@  discard block
 block discarded – undo
131 127
     /**
132 128
      * Enable a maintenance page for the given environment using the maintenance:enable Capistrano task.
133 129
      */
134
-    public function enableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
135
-    {
130
+    public function enableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) {
136 131
         $name = $environment->getFullName();
137 132
         $command = $this->getCommand('maintenance:enable', 'web', $environment, null, $log);
138 133
         $command->run(function ($type, $buffer) use ($log) {
@@ -148,8 +143,7 @@  discard block
 block discarded – undo
148 143
     /**
149 144
      * Disable the maintenance page for the given environment using the maintenance:disable Capistrano task.
150 145
      */
151
-    public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
152
-    {
146
+    public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) {
153 147
         $name = $environment->getFullName();
154 148
         $command = $this->getCommand('maintenance:disable', 'web', $environment, null, $log);
155 149
         $command->run(function ($type, $buffer) use ($log) {
@@ -165,8 +159,7 @@  discard block
 block discarded – undo
165 159
     /**
166 160
      * Check the status using the deploy:check capistrano method
167 161
      */
168
-    public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
169
-    {
162
+    public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) {
170 163
         $command = $this->getCommand('deploy:check', 'web', $environment, null, $log);
171 164
         $command->run(function ($type, $buffer) use ($log) {
172 165
             $log->write($buffer);
@@ -177,8 +170,7 @@  discard block
 block discarded – undo
177 170
     /**
178 171
      * @inheritdoc
179 172
      */
180
-    public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log)
181
-    {
173
+    public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
182 174
         if ($dataTransfer->Direction == 'get') {
183 175
             $this->dataTransferBackup($dataTransfer, $log);
184 176
         } else {
@@ -222,8 +214,7 @@  discard block
 block discarded – undo
222 214
      * @param DeploynautLogFile $log
223 215
      * @return \Symfony\Component\Process\Process
224 216
      */
225
-    public function getCommand($action, $roles, DNEnvironment $environment, $args = null, DeploynautLogFile $log)
226
-    {
217
+    public function getCommand($action, $roles, DNEnvironment $environment, $args = null, DeploynautLogFile $log) {
227 218
         $name = $environment->getFullName();
228 219
         $env = $environment->Project()->getProcessEnv();
229 220
 
@@ -277,8 +268,7 @@  discard block
 block discarded – undo
277 268
      * @param DNDataTransfer    $dataTransfer
278 269
      * @param DeploynautLogFile $log
279 270
      */
280
-    protected function dataTransferBackup(DNDataTransfer $dataTransfer, DeploynautLogFile $log)
281
-    {
271
+    protected function dataTransferBackup(DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
282 272
         $environment = $dataTransfer->Environment();
283 273
         $name = $environment->getFullName();
284 274
 
@@ -354,8 +344,7 @@  discard block
 block discarded – undo
354 344
      * Also cleans up and generates new error pages.
355 345
      * @param DeploynautLogFile $log
356 346
      */
357
-    public function rebuild(DNEnvironment $environment, $log)
358
-    {
347
+    public function rebuild(DNEnvironment $environment, $log) {
359 348
         $name = $environment->getFullName();
360 349
         $command = $this->getCommand('deploy:migrate', 'web', $environment, null, $log);
361 350
         $command->run(function ($type, $buffer) use ($log) {
@@ -376,8 +365,7 @@  discard block
 block discarded – undo
376 365
      * @param DNDataTransfer $dataTransfer
377 366
      * @param DeploynautLogFile $log
378 367
      */
379
-    protected function dataTransferRestore($workingDir, DNDataTransfer $dataTransfer, DeploynautLogFile $log)
380
-    {
368
+    protected function dataTransferRestore($workingDir, DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
381 369
         $environment = $dataTransfer->Environment();
382 370
         $name = $environment->getFullName();
383 371
 
Please login to merge, or discard this patch.
code/backends/DemoDeploymentBackend.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         $log->write("Well, that was a waste of time");
57 57
 
58 58
         // Once the deployment has run it's necessary to update the maintenance page status
59
-        if (!empty($options['leaveMaintenancePage'])) {
59
+        if(!empty($options['leaveMaintenancePage'])) {
60 60
             $this->enableMaintenance($environment, $log, $project);
61 61
         } else {
62 62
             // Remove maintenance page if we want it to
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  * It's useful for demonstrating how the system works, and how you can write deployment back-ends
9 9
  */
10
-class DemoDeploymentBackend extends Object implements DeploymentBackend
11
-{
10
+class DemoDeploymentBackend extends Object implements DeploymentBackend {
12 11
 
13 12
     /**
14 13
      * Create a deployment strategy.
@@ -18,8 +17,7 @@  discard block
 block discarded – undo
18 17
      *
19 18
      * @return DeploymentStrategy
20 19
      */
21
-    public function planDeploy(DNEnvironment $environment, $options = array())
22
-    {
20
+    public function planDeploy(DNEnvironment $environment, $options = array()) {
23 21
         return new DeploymentStrategy($environment, $options);
24 22
     }
25 23
 
@@ -69,23 +67,19 @@  discard block
 block discarded – undo
69 67
     /**
70 68
      * @inheritdoc
71 69
      */
72
-    public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log)
73
-    {
70
+    public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log) {
74 71
         die('Not implemented');
75 72
     }
76 73
 
77
-    public function enableMaintenance(DNEnvironment $environment, \DeploynautLogFile $log, DNProject $project)
78
-    {
74
+    public function enableMaintenance(DNEnvironment $environment, \DeploynautLogFile $log, DNProject $project) {
79 75
         $log->write(sprintf('Maintenance page enabled on "%s"', $environment->getFullName()));
80 76
     }
81 77
 
82
-    public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
83
-    {
78
+    public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) {
84 79
         $log->write(sprintf('Maintenance page disabled on "%s"', $environment->getFullName()));
85 80
     }
86 81
 
87
-    public function ping(\DNEnvironment $environment, DeploynautLogFile $log, DNProject $project)
88
-    {
82
+    public function ping(\DNEnvironment $environment, DeploynautLogFile $log, DNProject $project) {
89 83
         $log->write(sprintf('Ping "%s"', $environment->getFullName()));
90 84
     }
91 85
 }
Please login to merge, or discard this patch.
code/backends/DeploymentBackend.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-interface DeploymentBackend
4
-{
3
+interface DeploymentBackend {
5 4
 
6 5
     /**
7 6
      * Creates a deployment strategy that can be used to do some pre-flight checks.
Please login to merge, or discard this patch.
code/backends/DeploymentStrategy.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
     public function getChangesModificationNeeded()
142 142
     {
143 143
         $filtered = [];
144
-        foreach ($this->changes as $change => $details) {
145
-            if (array_key_exists('description', $details)) {
144
+        foreach($this->changes as $change => $details) {
145
+            if(array_key_exists('description', $details)) {
146 146
                 $filtered[$change] = $details;
147
-            } elseif (
147
+            } elseif(
148 148
                 (array_key_exists('from', $details) || array_key_exists('to', $details))
149 149
                 && $details['from'] !== $details['to']
150 150
             ) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public function getChange($key)
178 178
     {
179 179
         $changes = $this->getChanges();
180
-        if (array_key_exists($key, $changes)) {
180
+        if(array_key_exists($key, $changes)) {
181 181
             return new ArrayData($changes[$key]);
182 182
         }
183 183
         return null;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function getOption($option)
200 200
     {
201
-        if (!empty($this->options[$option])) {
201
+        if(!empty($this->options[$option])) {
202 202
             return $this->options[$option];
203 203
         }
204 204
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             DeploymentStrategy::WARNING_CODE => 1,
244 244
             DeploymentStrategy::ERROR_CODE => 2
245 245
         ];
246
-        if ($map[$current] < $map[$code]) {
246
+        if($map[$current] < $map[$code]) {
247 247
             $this->setValidationCode($code);
248 248
         }
249 249
     }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         );
275 275
 
276 276
         $output = array();
277
-        foreach ($fields as $field) {
277
+        foreach($fields as $field) {
278 278
             $output[$field] = $this->$field;
279 279
         }
280 280
         return $output;
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
             'messages'
319 319
         );
320 320
 
321
-        foreach ($fields as $field) {
322
-            if (!empty($data[$field])) {
321
+        foreach($fields as $field) {
322
+            if(!empty($data[$field])) {
323 323
                 $this->$field = $data[$field];
324 324
             }
325 325
         }
Please login to merge, or discard this patch.
Braces   +25 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DeploymentStrategy extends ViewableData
4
-{
3
+class DeploymentStrategy extends ViewableData {
5 4
 
6 5
     const SUCCESS_CODE = 'success';
7 6
 
@@ -56,8 +55,7 @@  discard block
 block discarded – undo
56 55
      * @param DNEnvironment $environment
57 56
      * @param array $options
58 57
      */
59
-    public function __construct(DNEnvironment $environment, $options = array())
60
-    {
58
+    public function __construct(DNEnvironment $environment, $options = array()) {
61 59
         $this->environment = $environment;
62 60
         $this->options = $options;
63 61
     }
@@ -65,47 +63,41 @@  discard block
 block discarded – undo
65 63
     /**
66 64
      * @param string $title
67 65
      */
68
-    public function setActionTitle($title)
69
-    {
66
+    public function setActionTitle($title) {
70 67
         $this->actionTitle = $title;
71 68
     }
72 69
 
73 70
     /**
74 71
      * @return string
75 72
      */
76
-    public function getActionTitle()
77
-    {
73
+    public function getActionTitle() {
78 74
         return $this->actionTitle;
79 75
     }
80 76
 
81 77
     /**
82 78
      */
83
-    public function setActionCode($code)
84
-    {
79
+    public function setActionCode($code) {
85 80
         $this->actionCode = $code;
86 81
     }
87 82
 
88 83
     /**
89 84
      * @return string
90 85
      */
91
-    public function getActionCode()
92
-    {
86
+    public function getActionCode() {
93 87
         return $this->actionCode;
94 88
     }
95 89
 
96 90
     /**
97 91
      * @param int
98 92
      */
99
-    public function setEstimatedTime($seconds)
100
-    {
93
+    public function setEstimatedTime($seconds) {
101 94
         $this->estimatedTime = $seconds;
102 95
     }
103 96
 
104 97
     /**
105 98
      * @return int Time in minutes
106 99
      */
107
-    public function getEstimatedTime()
108
-    {
100
+    public function getEstimatedTime() {
109 101
         return $this->estimatedTime;
110 102
     }
111 103
 
@@ -114,8 +106,7 @@  discard block
 block discarded – undo
114 106
      * @param string $from
115 107
      * @param string $to
116 108
      */
117
-    public function setChange($title, $from, $to)
118
-    {
109
+    public function setChange($title, $from, $to) {
119 110
         return $this->changes[$title] = array(
120 111
             'from' => $from,
121 112
             'to' => $to
@@ -126,8 +117,7 @@  discard block
 block discarded – undo
126 117
      * @param string $title
127 118
      * @param string $desc
128 119
      */
129
-    public function setChangeDescriptionOnly($title, $desc)
130
-    {
120
+    public function setChangeDescriptionOnly($title, $desc) {
131 121
         return $this->changes[$title] = array(
132 122
             'description' => $desc
133 123
         );
@@ -138,8 +128,7 @@  discard block
 block discarded – undo
138 128
      *
139 129
      * @return array
140 130
      */
141
-    public function getChangesModificationNeeded()
142
-    {
131
+    public function getChangesModificationNeeded() {
143 132
         $filtered = [];
144 133
         foreach ($this->changes as $change => $details) {
145 134
             if (array_key_exists('description', $details)) {
@@ -164,8 +153,7 @@  discard block
 block discarded – undo
164 153
      *		)
165 154
      *	)
166 155
      */
167
-    public function getChanges()
168
-    {
156
+    public function getChanges() {
169 157
         return $this->changes;
170 158
     }
171 159
 
@@ -174,8 +162,7 @@  discard block
 block discarded – undo
174 162
      *
175 163
      * @return ArrayData|null
176 164
      */
177
-    public function getChange($key)
178
-    {
165
+    public function getChange($key) {
179 166
         $changes = $this->getChanges();
180 167
         if (array_key_exists($key, $changes)) {
181 168
             return new ArrayData($changes[$key]);
@@ -187,8 +174,7 @@  discard block
 block discarded – undo
187 174
      * @param string $option
188 175
      * @param string $value
189 176
      */
190
-    public function setOption($option, $value)
191
-    {
177
+    public function setOption($option, $value) {
192 178
         $this->options[$option] = $value;
193 179
     }
194 180
 
@@ -196,8 +182,7 @@  discard block
 block discarded – undo
196 182
      * @param string $option
197 183
      * @return string|null
198 184
      */
199
-    public function getOption($option)
200
-    {
185
+    public function getOption($option) {
201 186
         if (!empty($this->options[$option])) {
202 187
             return $this->options[$option];
203 188
         }
@@ -206,32 +191,28 @@  discard block
 block discarded – undo
206 191
     /**
207 192
      * @return string
208 193
      */
209
-    public function getOptions()
210
-    {
194
+    public function getOptions() {
211 195
         return $this->options;
212 196
     }
213 197
 
214 198
     /**
215 199
      * @param string $code
216 200
      */
217
-    public function setValidationCode($code)
218
-    {
201
+    public function setValidationCode($code) {
219 202
         $this->validationCode = $code;
220 203
     }
221 204
 
222 205
     /**
223 206
      * @return string
224 207
      */
225
-    public function getValidationCode()
226
-    {
208
+    public function getValidationCode() {
227 209
         return $this->validationCode;
228 210
     }
229 211
 
230 212
     /**
231 213
      * @param string $msg
232 214
      */
233
-    public function setMessage($msg, $code = self::ERROR_CODE)
234
-    {
215
+    public function setMessage($msg, $code = self::ERROR_CODE) {
235 216
         $this->messages[] = [
236 217
             'text' => $msg,
237 218
             'code' => $code
@@ -251,8 +232,7 @@  discard block
 block discarded – undo
251 232
     /**
252 233
      * @return array
253 234
      */
254
-    public function getMessages()
255
-    {
235
+    public function getMessages() {
256 236
         return $this->messages;
257 237
     }
258 238
 
@@ -261,8 +241,7 @@  discard block
 block discarded – undo
261 241
      *
262 242
      * @return array
263 243
      */
264
-    public function toArray()
265
-    {
244
+    public function toArray() {
266 245
         $fields = array(
267 246
             'actionTitle',
268 247
             'actionCode',
@@ -283,8 +262,7 @@  discard block
 block discarded – undo
283 262
     /**
284 263
      * @return string
285 264
      */
286
-    public function toJSON()
287
-    {
265
+    public function toJSON() {
288 266
         return json_encode($this->toArray(), JSON_PRETTY_PRINT);
289 267
     }
290 268
 
@@ -294,8 +272,7 @@  discard block
 block discarded – undo
294 272
      *
295 273
      * @param string $json
296 274
      */
297
-    public function fromJSON($json)
298
-    {
275
+    public function fromJSON($json) {
299 276
         $decoded = json_decode($json, true);
300 277
         return $this->fromArray($decoded);
301 278
     }
@@ -306,8 +283,7 @@  discard block
 block discarded – undo
306 283
      *
307 284
      * @param string $data
308 285
      */
309
-    public function fromArray($data)
310
-    {
286
+    public function fromArray($data) {
311 287
         $fields = array(
312 288
             'actionTitle',
313 289
             'actionCode',
@@ -328,8 +304,7 @@  discard block
 block discarded – undo
328 304
     /**
329 305
      * @return DNDeployment
330 306
      */
331
-    public function createDeployment()
332
-    {
307
+    public function createDeployment() {
333 308
         $deployment = DNDeployment::create();
334 309
         $deployment->EnvironmentID = $this->environment->ID;
335 310
         // Pull out the SHA from the options so we can make it queryable.
Please login to merge, or discard this patch.
code/backends/EnvironmentCreateBackend.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-interface EnvironmentCreateBackend
4
-{
3
+interface EnvironmentCreateBackend {
5 4
 
6 5
     /**
7 6
      * @param DNCreateEnvironment $job
Please login to merge, or discard this patch.