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 | protected $optimizeAutoloader = false; |
||
126 | |||
127 | /** |
||
128 | * @var bool $createReplace |
||
129 | */ |
||
130 | 210 | protected $createReplace = false; |
|
131 | |||
132 | 210 | /** |
|
133 | 210 | * @param Composer $composer |
|
134 | */ |
||
135 | public function __construct(Composer $composer) |
||
139 | |||
140 | 175 | /** |
|
141 | 175 | * Load plugin settings |
|
142 | */ |
||
143 | 175 | public function loadSettings() |
|
175 | |||
176 | 175 | /** |
|
177 | * Get list of filenames and/or glob patterns to include |
||
178 | * |
||
179 | * @return array |
||
180 | */ |
||
181 | public function getIncludes() |
||
185 | |||
186 | 175 | /** |
|
187 | * Get list of filenames and/or glob patterns to require |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | public function getRequires() |
||
195 | |||
196 | 10 | /** |
|
197 | 10 | * Set the first install flag |
|
198 | * |
||
199 | * @param bool $flag |
||
200 | */ |
||
201 | public function setFirstInstall($flag) |
||
205 | |||
206 | 185 | /** |
|
207 | * Is this the first time that the plugin has been installed? |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | public function isFirstInstall() |
||
215 | |||
216 | 15 | /** |
|
217 | 15 | * Set the locked flag |
|
218 | * |
||
219 | * @param bool $flag |
||
220 | */ |
||
221 | public function setLocked($flag) |
||
225 | |||
226 | 20 | /** |
|
227 | * Was a lockfile present when the plugin was installed? |
||
228 | * |
||
229 | * @return bool |
||
230 | */ |
||
231 | public function isLocked() |
||
235 | |||
236 | 5 | /** |
|
237 | * Should an update be forced? |
||
238 | * |
||
239 | * @return true If packages are not locked |
||
240 | */ |
||
241 | public function forceUpdate() |
||
245 | |||
246 | 175 | /** |
|
247 | 175 | * Set the devMode flag |
|
248 | * |
||
249 | * @param bool $flag |
||
250 | */ |
||
251 | public function setDevMode($flag) |
||
255 | |||
256 | 170 | /** |
|
257 | * Should devMode settings be processed? |
||
258 | * |
||
259 | * @return bool |
||
260 | */ |
||
261 | public function isDevMode() |
||
265 | |||
266 | 170 | /** |
|
267 | * Should devMode settings be merged? |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function shouldMergeDev() |
||
275 | |||
276 | 175 | /** |
|
277 | 175 | * Set the dumpAutoloader flag |
|
278 | * |
||
279 | * @param bool $flag |
||
280 | */ |
||
281 | public function setDumpAutoloader($flag) |
||
285 | |||
286 | 5 | /** |
|
287 | * Is the autoloader file supposed to be written out? |
||
288 | * |
||
289 | * @return bool |
||
290 | */ |
||
291 | public function shouldDumpAutoloader() |
||
295 | |||
296 | 175 | /** |
|
297 | 175 | * Set the optimizeAutoloader flag |
|
298 | * |
||
299 | * @param bool $flag |
||
300 | */ |
||
301 | public function setOptimizeAutoloader($flag) |
||
305 | |||
306 | 5 | /** |
|
307 | * Should the autoloader be optimized? |
||
308 | * |
||
309 | * @return bool |
||
310 | */ |
||
311 | public function shouldOptimizeAutoloader() |
||
315 | 95 | ||
316 | /** |
||
317 | 95 | * Add duplicate packages |
|
318 | 95 | * |
|
319 | 95 | * @param string $type Package type |
|
320 | 95 | * @param array $packages |
|
321 | 95 | */ |
|
322 | 95 | public function addDuplicateLinks($type, array $packages) |
|
330 | 170 | ||
331 | /** |
||
332 | 170 | * Get duplicate packages |
|
333 | 170 | * |
|
334 | * @param string $type Package type |
||
335 | * @return array |
||
336 | */ |
||
337 | public function getDuplicateLinks($type) |
||
342 | |||
343 | 170 | /** |
|
344 | * Should includes be recursively processed? |
||
345 | * |
||
346 | * @return bool |
||
347 | */ |
||
348 | public function recurseIncludes() |
||
352 | |||
353 | 95 | /** |
|
354 | * Should duplicate links be replaced in a 'last definition wins' order? |
||
355 | * |
||
356 | * @return bool |
||
357 | */ |
||
358 | public function replaceDuplicateLinks() |
||
362 | |||
363 | 95 | /** |
|
364 | * Should duplicate links be ignored? |
||
365 | * |
||
366 | * @return bool |
||
367 | */ |
||
368 | public function ignoreDuplicateLinks() |
||
372 | |||
373 | /** |
||
374 | * Should the extra section be merged? |
||
375 | * |
||
376 | * By default, the extra section is not merged and there will be many |
||
377 | * cases where the merge of the extra section is performed too late |
||
378 | 170 | * to be of use to other plugins. When enabled, merging uses one of |
|
379 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
380 | 170 | * 'first wins' is the default behaviour. If Replace mode is activated |
|
381 | * then 'last wins' is used. |
||
382 | * |
||
383 | * @return bool |
||
384 | */ |
||
385 | public function shouldMergeExtra() |
||
389 | |||
390 | /** |
||
391 | * Should the extra section be merged deep / recursively? |
||
392 | * |
||
393 | * By default the extra section is merged with array_merge() and duplicate |
||
394 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
395 | * using the following rule: Integer keys are merged, while array values are |
||
396 | * replaced where the later values overwrite the former. |
||
397 | * |
||
398 | * This is useful especially for the extra section when plugins use larger |
||
399 | 30 | * structures like a 'patches' key with the packages as sub-keys and the |
|
400 | * patches as values. |
||
401 | 30 | * |
|
402 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
403 | * |
||
404 | * @return bool |
||
405 | */ |
||
406 | public function shouldMergeExtraDeep() |
||
410 | |||
411 | |||
412 | 170 | /** |
|
413 | * Should the scripts section be merged? |
||
414 | 170 | * |
|
415 | * By default, the scripts section is not merged. |
||
416 | * |
||
417 | * @return bool |
||
418 | */ |
||
419 | public function shouldMergeScripts() |
||
423 | |||
424 | /** |
||
425 | * Should the root package add all sub-packages to the root "replace" |
||
426 | * |
||
427 | * @return bool |
||
428 | */ |
||
429 | public function shouldCreateReplace() |
||
433 | |||
434 | } |
||
435 | // vim:sw=4:ts=4:sts=4:et: |
||
436 |