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 | * @var bool $ignore |
||
59 | */ |
||
60 | protected $ignore = false; |
||
61 | |||
62 | /** |
||
63 | * Whether to merge the -dev sections. |
||
64 | * @var bool $mergeDev |
||
65 | */ |
||
66 | protected $mergeDev = true; |
||
67 | |||
68 | /** |
||
69 | * Whether to merge the extra section. |
||
70 | * |
||
71 | * By default, the extra section is not merged and there will be many |
||
72 | * cases where the merge of the extra section is performed too late |
||
73 | * to be of use to other plugins. When enabled, merging uses one of |
||
74 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
75 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
76 | * then 'last wins' is used. |
||
77 | * |
||
78 | * @var bool $mergeExtra |
||
79 | */ |
||
80 | protected $mergeExtra = false; |
||
81 | |||
82 | /** |
||
83 | * Whether to merge the extra section in a deep / recursive way. |
||
84 | * |
||
85 | * By default the extra section is merged with array_merge() and duplicate |
||
86 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
87 | * using the following rule: Integer keys are merged, while array values are |
||
88 | * replaced where the later values overwrite the former. |
||
89 | * |
||
90 | * This is useful especially for the extra section when plugins use larger |
||
91 | * structures like a 'patches' key with the packages as sub-keys and the |
||
92 | * patches as values. |
||
93 | * |
||
94 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
95 | * |
||
96 | * @var bool $mergeExtraDeep |
||
97 | */ |
||
98 | protected $mergeExtraDeep = false; |
||
99 | |||
100 | /** |
||
101 | * Whether to merge the scripts section. |
||
102 | * |
||
103 | * @var bool $mergeScripts |
||
104 | */ |
||
105 | protected $mergeScripts = false; |
||
106 | |||
107 | /** |
||
108 | * @var bool $firstInstall |
||
109 | */ |
||
110 | protected $firstInstall = false; |
||
111 | |||
112 | /** |
||
113 | * @var bool $locked |
||
114 | */ |
||
115 | protected $locked = false; |
||
116 | |||
117 | /** |
||
118 | * @var bool $dumpAutoloader |
||
119 | */ |
||
120 | protected $dumpAutoloader = false; |
||
121 | |||
122 | /** |
||
123 | * @var bool $optimizeAutoloader |
||
124 | */ |
||
125 | 200 | protected $optimizeAutoloader = false; |
|
126 | |||
127 | 200 | /** |
|
128 | 200 | * @param Composer $composer |
|
129 | */ |
||
130 | public function __construct(Composer $composer) |
||
134 | |||
135 | 165 | /** |
|
136 | 165 | * Load plugin settings |
|
137 | */ |
||
138 | 165 | public function loadSettings() |
|
168 | |||
169 | 165 | /** |
|
170 | * Get list of filenames and/or glob patterns to include |
||
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | public function getIncludes() |
||
178 | |||
179 | 165 | /** |
|
180 | * Get list of filenames and/or glob patterns to require |
||
181 | * |
||
182 | * @return array |
||
183 | */ |
||
184 | public function getRequires() |
||
188 | |||
189 | 10 | /** |
|
190 | 10 | * Set the first install flag |
|
191 | * |
||
192 | * @param bool $flag |
||
193 | */ |
||
194 | public function setFirstInstall($flag) |
||
198 | |||
199 | 175 | /** |
|
200 | * Is this the first time that the plugin has been installed? |
||
201 | * |
||
202 | * @return bool |
||
203 | */ |
||
204 | public function isFirstInstall() |
||
208 | |||
209 | 15 | /** |
|
210 | 15 | * Set the locked flag |
|
211 | * |
||
212 | * @param bool $flag |
||
213 | */ |
||
214 | public function setLocked($flag) |
||
218 | |||
219 | 20 | /** |
|
220 | * Was a lockfile present when the plugin was installed? |
||
221 | * |
||
222 | * @return bool |
||
223 | */ |
||
224 | public function isLocked() |
||
228 | |||
229 | 5 | /** |
|
230 | * Should an update be forced? |
||
231 | * |
||
232 | * @return true If packages are not locked |
||
233 | */ |
||
234 | public function forceUpdate() |
||
238 | |||
239 | 165 | /** |
|
240 | 165 | * Set the devMode flag |
|
241 | * |
||
242 | * @param bool $flag |
||
243 | */ |
||
244 | public function setDevMode($flag) |
||
248 | |||
249 | 160 | /** |
|
250 | * Should devMode settings be processed? |
||
251 | * |
||
252 | * @return bool |
||
253 | */ |
||
254 | public function isDevMode() |
||
258 | |||
259 | 160 | /** |
|
260 | * Should devMode settings be merged? |
||
261 | * |
||
262 | * @return bool |
||
263 | */ |
||
264 | public function shouldMergeDev() |
||
268 | |||
269 | 165 | /** |
|
270 | 165 | * Set the dumpAutoloader flag |
|
271 | * |
||
272 | * @param bool $flag |
||
273 | */ |
||
274 | public function setDumpAutoloader($flag) |
||
278 | |||
279 | 5 | /** |
|
280 | * Is the autoloader file supposed to be written out? |
||
281 | * |
||
282 | * @return bool |
||
283 | */ |
||
284 | public function shouldDumpAutoloader() |
||
288 | |||
289 | 165 | /** |
|
290 | 165 | * Set the optimizeAutoloader flag |
|
291 | * |
||
292 | * @param bool $flag |
||
293 | */ |
||
294 | public function setOptimizeAutoloader($flag) |
||
298 | |||
299 | 5 | /** |
|
300 | * Should the autoloader be optimized? |
||
301 | * |
||
302 | * @return bool |
||
303 | */ |
||
304 | public function shouldOptimizeAutoloader() |
||
308 | 85 | ||
309 | /** |
||
310 | 85 | * Add duplicate packages |
|
311 | 85 | * |
|
312 | 85 | * @param string $type Package type |
|
313 | 85 | * @param array $packages |
|
314 | 85 | */ |
|
315 | 85 | public function addDuplicateLinks($type, array $packages) |
|
323 | 160 | ||
324 | /** |
||
325 | 160 | * Get duplicate packages |
|
326 | 160 | * |
|
327 | * @param string $type Package type |
||
328 | * @return array |
||
329 | */ |
||
330 | public function getDuplicateLinks($type) |
||
335 | |||
336 | 160 | /** |
|
337 | * Should includes be recursively processed? |
||
338 | * |
||
339 | * @return bool |
||
340 | */ |
||
341 | public function recurseIncludes() |
||
345 | |||
346 | 85 | /** |
|
347 | * Should duplicate links be replaced in a 'last definition wins' order? |
||
348 | * |
||
349 | * @return bool |
||
350 | */ |
||
351 | public function replaceDuplicateLinks() |
||
355 | |||
356 | /** |
||
357 | * Should duplicate links be ignored? |
||
358 | * |
||
359 | * @return bool |
||
360 | */ |
||
361 | 160 | public function ignoreDuplicateLinks() |
|
362 | { |
||
363 | 160 | return $this->ignore; |
|
364 | } |
||
365 | |||
366 | /** |
||
367 | * Should the extra section be merged? |
||
368 | * |
||
369 | * By default, the extra section is not merged and there will be many |
||
370 | * cases where the merge of the extra section is performed too late |
||
371 | * to be of use to other plugins. When enabled, merging uses one of |
||
372 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
373 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
374 | * then 'last wins' is used. |
||
375 | * |
||
376 | * @return bool |
||
377 | */ |
||
378 | public function shouldMergeExtra() |
||
382 | 30 | ||
383 | /** |
||
384 | 30 | * Should the extra section be merged deep / recursively? |
|
385 | * |
||
386 | * By default the extra section is merged with array_merge() and duplicate |
||
387 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
388 | * using the following rule: Integer keys are merged, while array values are |
||
389 | * replaced where the later values overwrite the former. |
||
390 | * |
||
391 | * This is useful especially for the extra section when plugins use larger |
||
392 | * structures like a 'patches' key with the packages as sub-keys and the |
||
393 | * patches as values. |
||
394 | * |
||
395 | 160 | * When 'replace' mode is activated the order of array merges is exchanged. |
|
396 | * |
||
397 | 160 | * @return bool |
|
398 | */ |
||
399 | public function shouldMergeExtraDeep() |
||
403 | |||
404 | |||
405 | /** |
||
406 | * Should the scripts section be merged? |
||
407 | * |
||
408 | * By default, the scripts section is not merged. |
||
409 | * |
||
410 | * @return bool |
||
411 | */ |
||
412 | public function shouldMergeScripts() |
||
416 | } |
||
417 | // vim:sw=4:ts=4:sts=4:et: |
||
418 |