1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Conveyor package. |
5
|
|
|
* |
6
|
|
|
* (c) Jeroen Fiege <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Webcreate\Conveyor; |
13
|
|
|
|
14
|
|
|
use Webcreate\Conveyor\Repository\Version; |
15
|
|
|
use Webcreate\Conveyor\Strategy\StrategyInterface; |
16
|
|
|
use Webcreate\Conveyor\Util\FileCollection; |
17
|
|
|
|
18
|
|
|
class Context |
19
|
|
|
{ |
20
|
|
|
protected $isFullDeploy = false; |
21
|
|
|
protected $isSimulate = false; |
22
|
|
|
protected $buildDir; |
23
|
|
|
protected $filesModified; |
24
|
|
|
protected $filesDeleted; |
25
|
|
|
protected $force = false; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Version |
29
|
|
|
*/ |
30
|
|
|
protected $version; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var Version |
34
|
|
|
*/ |
35
|
|
|
protected $remoteVersion; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $target; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var StrategyInterface |
44
|
|
|
*/ |
45
|
|
|
protected $strategy; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Constructor. |
49
|
|
|
*/ |
50
|
7 |
|
public function __construct() |
51
|
|
|
{ |
52
|
7 |
|
$this->filesModified = new FileCollection(); |
53
|
7 |
|
$this->filesDeleted = new FileCollection(); |
54
|
7 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getTarget() |
60
|
|
|
{ |
61
|
|
|
return $this->target; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function getRemoteVersion() |
68
|
|
|
{ |
69
|
|
|
return $this->remoteVersion; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param Version $remoteVersion |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setRemoteVersion(Version $remoteVersion) |
77
|
|
|
{ |
78
|
|
|
$this->remoteVersion = $remoteVersion; |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $target |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
public function setTarget($target) |
88
|
|
|
{ |
89
|
|
|
$this->target = $target; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return Version |
96
|
|
|
*/ |
97
|
|
|
public function getVersion() |
98
|
|
|
{ |
99
|
|
|
return $this->version; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param Version $version |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
|
|
public function setVersion(Version $version) |
107
|
|
|
{ |
108
|
|
|
$this->version = $version; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param FileCollection $filesDeleted |
115
|
|
|
* @return $this |
116
|
|
|
*/ |
117
|
|
|
public function setFilesDeleted($filesDeleted) |
118
|
|
|
{ |
119
|
|
|
$this->filesDeleted = $filesDeleted; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return FileCollection |
126
|
|
|
*/ |
127
|
|
|
public function getFilesDeleted() |
128
|
|
|
{ |
129
|
|
|
return $this->filesDeleted; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param FileCollection $filesModified |
134
|
|
|
* @return $this |
135
|
|
|
*/ |
136
|
|
|
public function setFilesModified($filesModified) |
137
|
|
|
{ |
138
|
|
|
$this->filesModified = $filesModified; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return FileCollection |
145
|
|
|
*/ |
146
|
|
|
public function getFilesModified() |
147
|
|
|
{ |
148
|
|
|
return $this->filesModified; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return mixed |
153
|
|
|
*/ |
154
|
|
|
public function getBuilddir() |
155
|
|
|
{ |
156
|
|
|
return $this->buildDir; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param string $buildDir |
161
|
|
|
* @return $this |
162
|
|
|
*/ |
163
|
|
|
public function setBuilddir($buildDir) |
164
|
|
|
{ |
165
|
|
|
$this->buildDir = $buildDir; |
166
|
|
|
|
167
|
|
|
$this->filesModified->setBasepath($this->buildDir); |
168
|
|
|
$this->filesDeleted->setBasepath($this->buildDir); |
169
|
|
|
|
170
|
|
|
return $this; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param $value |
175
|
|
|
* @return $this |
176
|
|
|
*/ |
177
|
|
|
public function setFullDeploy($value) |
178
|
|
|
{ |
179
|
|
|
$this->isFullDeploy = (bool) $value; |
180
|
|
|
|
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return bool |
186
|
|
|
*/ |
187
|
|
|
public function isFullDeploy() |
188
|
|
|
{ |
189
|
|
|
return $this->isFullDeploy; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param boolean $value |
194
|
|
|
* @return $this |
195
|
|
|
*/ |
196
|
|
|
public function setSimulate($value) |
197
|
|
|
{ |
198
|
|
|
$this->isSimulate = (bool) $value; |
199
|
|
|
|
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return bool |
205
|
|
|
*/ |
206
|
|
|
public function isSimulate() |
207
|
|
|
{ |
208
|
|
|
return $this->isSimulate; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param StrategyInterface $strategy |
213
|
|
|
* @return $this |
214
|
|
|
*/ |
215
|
|
|
public function setStrategy(StrategyInterface $strategy) |
216
|
|
|
{ |
217
|
|
|
$this->strategy = $strategy; |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @return StrategyInterface |
224
|
|
|
*/ |
225
|
|
|
public function getStrategy() |
226
|
|
|
{ |
227
|
|
|
return $this->strategy; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return boolean |
232
|
|
|
*/ |
233
|
|
|
public function isForce() |
234
|
|
|
{ |
235
|
|
|
return $this->force; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @param boolean $force |
240
|
|
|
* @return $this |
241
|
|
|
*/ |
242
|
|
|
public function setForce($force) |
243
|
|
|
{ |
244
|
|
|
$this->force = $force; |
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|