1 | <?php |
||
20 | class PluginState |
||
21 | { |
||
22 | /** |
||
23 | * @var Composer $composer |
||
24 | */ |
||
25 | protected $composer; |
||
26 | |||
27 | /** |
||
28 | * @var array $includes |
||
29 | */ |
||
30 | protected $includes = array(); |
||
31 | |||
32 | /** |
||
33 | * @var array $requires |
||
34 | */ |
||
35 | protected $requires = array(); |
||
36 | |||
37 | /** |
||
38 | * @var array $duplicateLinks |
||
39 | */ |
||
40 | protected $duplicateLinks = array(); |
||
41 | |||
42 | /** |
||
43 | * @var bool $devMode |
||
44 | */ |
||
45 | protected $devMode = false; |
||
46 | |||
47 | /** |
||
48 | * @var bool $recurse |
||
49 | */ |
||
50 | protected $recurse = true; |
||
51 | |||
52 | /** |
||
53 | * @var bool $replace |
||
54 | */ |
||
55 | protected $replace = false; |
||
56 | |||
57 | /** |
||
58 | * Whether to merge the -dev sections. |
||
59 | * @var bool $mergeDev |
||
60 | */ |
||
61 | protected $mergeDev = true; |
||
62 | |||
63 | /** |
||
64 | * Whether to merge the extra section. |
||
65 | * |
||
66 | * By default, the extra section is not merged and there will be many |
||
67 | * cases where the merge of the extra section is performed too late |
||
68 | * to be of use to other plugins. When enabled, merging uses one of |
||
69 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
70 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
71 | * then 'last wins' is used. |
||
72 | * |
||
73 | * @var bool $mergeExtra |
||
74 | */ |
||
75 | protected $mergeExtra = false; |
||
76 | |||
77 | /** |
||
78 | * Whether to merge the extra section in a deep / recursive way. |
||
79 | * |
||
80 | * By default the extra section is merged with array_merge() and duplicate |
||
81 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
82 | * using the following rule: Integer keys are merged, while array values are |
||
83 | * replaced where the later values overwrite the former. |
||
84 | * |
||
85 | * This is useful especially for the extra section when plugins use larger |
||
86 | * structures like a 'patches' key with the packages as sub-keys and the |
||
87 | * patches as values. |
||
88 | * |
||
89 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
90 | * |
||
91 | * @var bool $mergeExtraDeep |
||
92 | */ |
||
93 | protected $mergeExtraDeep = false; |
||
94 | |||
95 | /** |
||
96 | * @var bool $firstInstall |
||
97 | */ |
||
98 | protected $firstInstall = false; |
||
99 | |||
100 | /** |
||
101 | * @var bool $locked |
||
102 | */ |
||
103 | protected $locked = false; |
||
104 | |||
105 | /** |
||
106 | * @var bool $dumpAutoloader |
||
107 | */ |
||
108 | protected $dumpAutoloader = false; |
||
109 | |||
110 | /** |
||
111 | * @var bool $optimizeAutoloader |
||
112 | */ |
||
113 | protected $optimizeAutoloader = false; |
||
114 | |||
115 | /** |
||
116 | * @param Composer $composer |
||
117 | */ |
||
118 | 180 | public function __construct(Composer $composer) |
|
122 | |||
123 | /** |
||
124 | * Load plugin settings |
||
125 | */ |
||
126 | 145 | public function loadSettings() |
|
152 | |||
153 | /** |
||
154 | * Get list of filenames and/or glob patterns to include |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | 145 | public function getIncludes() |
|
162 | |||
163 | /** |
||
164 | * Get list of filenames and/or glob patterns to require |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | 145 | public function getRequires() |
|
172 | |||
173 | /** |
||
174 | * Set the first install flag |
||
175 | * |
||
176 | * @param bool $flag |
||
177 | */ |
||
178 | 10 | public function setFirstInstall($flag) |
|
182 | |||
183 | /** |
||
184 | * Is this the first time that the plugin has been installed? |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | 155 | public function isFirstInstall() |
|
192 | |||
193 | /** |
||
194 | * Set the locked flag |
||
195 | * |
||
196 | * @param bool $flag |
||
197 | */ |
||
198 | 15 | public function setLocked($flag) |
|
202 | |||
203 | /** |
||
204 | * Was a lockfile present when the plugin was installed? |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | 20 | public function isLocked() |
|
212 | |||
213 | /** |
||
214 | * Should an update be forced? |
||
215 | * |
||
216 | * @return true If packages are not locked |
||
217 | */ |
||
218 | 5 | public function forceUpdate() |
|
222 | |||
223 | /** |
||
224 | * Set the devMode flag |
||
225 | * |
||
226 | * @param bool $flag |
||
227 | */ |
||
228 | 145 | public function setDevMode($flag) |
|
232 | |||
233 | /** |
||
234 | * Should devMode settings be processed? |
||
235 | * |
||
236 | * @return bool |
||
237 | */ |
||
238 | 140 | public function isDevMode() |
|
242 | |||
243 | /** |
||
244 | * Should devMode settings be merged? |
||
245 | * |
||
246 | * @return bool |
||
247 | */ |
||
248 | 140 | public function shouldMergeDev() |
|
252 | |||
253 | /** |
||
254 | * Set the dumpAutoloader flag |
||
255 | * |
||
256 | * @param bool $flag |
||
257 | */ |
||
258 | 145 | public function setDumpAutoloader($flag) |
|
262 | |||
263 | /** |
||
264 | * Is the autoloader file supposed to be written out? |
||
265 | * |
||
266 | * @return bool |
||
267 | */ |
||
268 | 5 | public function shouldDumpAutoloader() |
|
272 | |||
273 | /** |
||
274 | * Set the optimizeAutoloader flag |
||
275 | * |
||
276 | * @param bool $flag |
||
277 | */ |
||
278 | 145 | public function setOptimizeAutoloader($flag) |
|
282 | |||
283 | /** |
||
284 | * Should the autoloader be optimized? |
||
285 | * |
||
286 | * @return bool |
||
287 | */ |
||
288 | 5 | public function shouldOptimizeAutoloader() |
|
292 | |||
293 | /** |
||
294 | * Add duplicate packages |
||
295 | * |
||
296 | * @param string $type Package type |
||
297 | * @param array $packages |
||
298 | */ |
||
299 | 85 | public function addDuplicateLinks($type, array $packages) |
|
307 | |||
308 | /** |
||
309 | * Get duplicate packages |
||
310 | * |
||
311 | * @param string $type Package type |
||
312 | * @return array |
||
313 | */ |
||
314 | 140 | public function getDuplicateLinks($type) |
|
319 | |||
320 | /** |
||
321 | * Should includes be recursively processed? |
||
322 | * |
||
323 | * @return bool |
||
324 | */ |
||
325 | 140 | public function recurseIncludes() |
|
329 | |||
330 | /** |
||
331 | * Should duplicate links be replaced in a 'last definition wins' order? |
||
332 | * |
||
333 | * @return bool |
||
334 | */ |
||
335 | 65 | public function replaceDuplicateLinks() |
|
339 | |||
340 | /** |
||
341 | * Should the extra section be merged? |
||
342 | * |
||
343 | * By default, the extra section is not merged and there will be many |
||
344 | * cases where the merge of the extra section is performed too late |
||
345 | * to be of use to other plugins. When enabled, merging uses one of |
||
346 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
347 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
348 | * then 'last wins' is used. |
||
349 | * |
||
350 | * @return bool |
||
351 | */ |
||
352 | 140 | public function shouldMergeExtra() |
|
356 | |||
357 | /** |
||
358 | * Should the extra section be merged deep / recursively? |
||
359 | * |
||
360 | * By default the extra section is merged with array_merge() and duplicate |
||
361 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
362 | * using the following rule: Integer keys are merged, while array values are |
||
363 | * replaced where the later values overwrite the former. |
||
364 | * |
||
365 | * This is useful especially for the extra section when plugins use larger |
||
366 | * structures like a 'patches' key with the packages as sub-keys and the |
||
367 | * patches as values. |
||
368 | * |
||
369 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
370 | * |
||
371 | * @return bool |
||
372 | */ |
||
373 | 30 | public function shouldMergeExtraDeep() |
|
377 | } |
||
378 | // vim:sw=4:ts=4:sts=4:et: |
||
379 |