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 | * Whether to merge the scripts section. |
||
97 | * |
||
98 | * @var bool $mergeScripts |
||
99 | */ |
||
100 | protected $mergeScripts = false; |
||
101 | |||
102 | /** |
||
103 | * @var bool $firstInstall |
||
104 | */ |
||
105 | protected $firstInstall = false; |
||
106 | |||
107 | /** |
||
108 | * @var bool $locked |
||
109 | */ |
||
110 | protected $locked = false; |
||
111 | |||
112 | /** |
||
113 | * @var bool $dumpAutoloader |
||
114 | */ |
||
115 | protected $dumpAutoloader = false; |
||
116 | |||
117 | /** |
||
118 | 180 | * @var bool $optimizeAutoloader |
|
119 | */ |
||
120 | 180 | protected $optimizeAutoloader = false; |
|
121 | 180 | ||
122 | /** |
||
123 | * @param Composer $composer |
||
124 | */ |
||
125 | public function __construct(Composer $composer) |
||
129 | 145 | ||
130 | /** |
||
131 | 145 | * Load plugin settings |
|
132 | 145 | */ |
|
133 | 145 | public function loadSettings() |
|
161 | |||
162 | /** |
||
163 | * Get list of filenames and/or glob patterns to include |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | public function getIncludes() |
||
171 | |||
172 | /** |
||
173 | * Get list of filenames and/or glob patterns to require |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | public function getRequires() |
||
181 | 10 | ||
182 | /** |
||
183 | * Set the first install flag |
||
184 | * |
||
185 | * @param bool $flag |
||
186 | */ |
||
187 | public function setFirstInstall($flag) |
||
191 | |||
192 | /** |
||
193 | * Is this the first time that the plugin has been installed? |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | public function isFirstInstall() |
||
201 | 15 | ||
202 | /** |
||
203 | * Set the locked flag |
||
204 | * |
||
205 | * @param bool $flag |
||
206 | */ |
||
207 | public function setLocked($flag) |
||
211 | |||
212 | /** |
||
213 | * Was a lockfile present when the plugin was installed? |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function isLocked() |
||
221 | |||
222 | /** |
||
223 | * Should an update be forced? |
||
224 | * |
||
225 | * @return true If packages are not locked |
||
226 | */ |
||
227 | public function forceUpdate() |
||
231 | 145 | ||
232 | /** |
||
233 | * Set the devMode flag |
||
234 | * |
||
235 | * @param bool $flag |
||
236 | */ |
||
237 | public function setDevMode($flag) |
||
241 | |||
242 | /** |
||
243 | * Should devMode settings be processed? |
||
244 | * |
||
245 | * @return bool |
||
246 | */ |
||
247 | public function isDevMode() |
||
251 | |||
252 | /** |
||
253 | * Should devMode settings be merged? |
||
254 | * |
||
255 | * @return bool |
||
256 | */ |
||
257 | public function shouldMergeDev() |
||
261 | 145 | ||
262 | /** |
||
263 | * Set the dumpAutoloader flag |
||
264 | * |
||
265 | * @param bool $flag |
||
266 | */ |
||
267 | public function setDumpAutoloader($flag) |
||
271 | |||
272 | /** |
||
273 | * Is the autoloader file supposed to be written out? |
||
274 | * |
||
275 | * @return bool |
||
276 | */ |
||
277 | public function shouldDumpAutoloader() |
||
281 | 145 | ||
282 | /** |
||
283 | * Set the optimizeAutoloader flag |
||
284 | * |
||
285 | * @param bool $flag |
||
286 | */ |
||
287 | public function setOptimizeAutoloader($flag) |
||
291 | |||
292 | /** |
||
293 | * Should the autoloader be optimized? |
||
294 | * |
||
295 | * @return bool |
||
296 | */ |
||
297 | public function shouldOptimizeAutoloader() |
||
301 | 85 | ||
302 | 85 | /** |
|
303 | 85 | * Add duplicate packages |
|
304 | 85 | * |
|
305 | 85 | * @param string $type Package type |
|
306 | 85 | * @param array $packages |
|
307 | */ |
||
308 | public function addDuplicateLinks($type, array $packages) |
||
316 | 140 | ||
317 | 140 | /** |
|
318 | * Get duplicate packages |
||
319 | * |
||
320 | * @param string $type Package type |
||
321 | * @return array |
||
322 | */ |
||
323 | public function getDuplicateLinks($type) |
||
328 | |||
329 | /** |
||
330 | * Should includes be recursively processed? |
||
331 | * |
||
332 | * @return bool |
||
333 | */ |
||
334 | public function recurseIncludes() |
||
338 | |||
339 | /** |
||
340 | * Should duplicate links be replaced in a 'last definition wins' order? |
||
341 | * |
||
342 | * @return bool |
||
343 | */ |
||
344 | public function replaceDuplicateLinks() |
||
348 | |||
349 | /** |
||
350 | * Should the extra section be merged? |
||
351 | * |
||
352 | 140 | * By default, the extra section is not merged and there will be many |
|
353 | * cases where the merge of the extra section is performed too late |
||
354 | 140 | * to be of use to other plugins. When enabled, merging uses one of |
|
355 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
356 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
357 | * then 'last wins' is used. |
||
358 | * |
||
359 | * @return bool |
||
360 | */ |
||
361 | public function shouldMergeExtra() |
||
365 | |||
366 | /** |
||
367 | * Should the extra section be merged deep / recursively? |
||
368 | * |
||
369 | * By default the extra section is merged with array_merge() and duplicate |
||
370 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
371 | * using the following rule: Integer keys are merged, while array values are |
||
372 | * replaced where the later values overwrite the former. |
||
373 | 30 | * |
|
374 | * This is useful especially for the extra section when plugins use larger |
||
375 | 30 | * structures like a 'patches' key with the packages as sub-keys and the |
|
376 | * patches as values. |
||
377 | * |
||
378 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
379 | * |
||
380 | * @return bool |
||
381 | */ |
||
382 | public function shouldMergeExtraDeep() |
||
386 | |||
387 | |||
388 | /** |
||
389 | * Should the scripts section be merged? |
||
390 | * |
||
391 | * By default, the scripts section is not merged. |
||
392 | * |
||
393 | * @return bool |
||
394 | */ |
||
395 | public function shouldMergeScripts() |
||
399 | } |
||
400 | // vim:sw=4:ts=4:sts=4:et: |
||
401 |