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 prepend repositories to repository manager. |
||
79 | * |
||
80 | * @var bool $prependRepositories |
||
81 | */ |
||
82 | protected $prependRepositories = false; |
||
83 | |||
84 | /** |
||
85 | * Whether to merge the extra section in a deep / recursive way. |
||
86 | * |
||
87 | * By default the extra section is merged with array_merge() and duplicate |
||
88 | * keys are ignored. When enabled this allows to merge the arrays recursively |
||
89 | * using the following rule: Integer keys are merged, while array values are |
||
90 | * replaced where the later values overwrite the former. |
||
91 | * |
||
92 | * This is useful especially for the extra section when plugins use larger |
||
93 | * structures like a 'patches' key with the packages as sub-keys and the |
||
94 | * patches as values. |
||
95 | * |
||
96 | * When 'replace' mode is activated the order of array merges is exchanged. |
||
97 | * |
||
98 | * @var bool $mergeExtraDeep |
||
99 | */ |
||
100 | protected $mergeExtraDeep = 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 | * @var bool $optimizeAutoloader |
||
119 | */ |
||
120 | protected $optimizeAutoloader = false; |
||
121 | |||
122 | /** |
||
123 | * @param Composer $composer |
||
124 | */ |
||
125 | 140 | public function __construct(Composer $composer) |
|
129 | |||
130 | /** |
||
131 | * Load plugin settings |
||
132 | */ |
||
133 | 105 | public function loadSettings() |
|
161 | |||
162 | /** |
||
163 | * Get list of filenames and/or glob patterns to include |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | 105 | public function getIncludes() |
|
171 | |||
172 | /** |
||
173 | * Get list of filenames and/or glob patterns to require |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | 105 | public function getRequires() |
|
181 | |||
182 | /** |
||
183 | * Set the first install flag |
||
184 | * |
||
185 | * @param bool $flag |
||
186 | */ |
||
187 | 10 | public function setFirstInstall($flag) |
|
191 | |||
192 | /** |
||
193 | * Is this the first time that the plugin has been installed? |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | 115 | public function isFirstInstall() |
|
201 | |||
202 | /** |
||
203 | * Set the locked flag |
||
204 | * |
||
205 | * @param bool $flag |
||
206 | */ |
||
207 | 15 | public function setLocked($flag) |
|
211 | |||
212 | /** |
||
213 | * Was a lockfile present when the plugin was installed? |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | 20 | public function isLocked() |
|
221 | |||
222 | /** |
||
223 | * Should an update be forced? |
||
224 | * |
||
225 | * @return true If packages are not locked |
||
226 | */ |
||
227 | 5 | public function forceUpdate() |
|
231 | |||
232 | /** |
||
233 | * Set the devMode flag |
||
234 | * |
||
235 | * @param bool $flag |
||
236 | */ |
||
237 | 105 | public function setDevMode($flag) |
|
241 | |||
242 | /** |
||
243 | * Should devMode settings be processed? |
||
244 | * |
||
245 | * @return bool |
||
246 | */ |
||
247 | 100 | public function isDevMode() |
|
251 | |||
252 | /** |
||
253 | * Set the dumpAutoloader flag |
||
254 | * |
||
255 | * @param bool $flag |
||
256 | */ |
||
257 | 105 | public function setDumpAutoloader($flag) |
|
261 | |||
262 | /** |
||
263 | * Is the autoloader file supposed to be written out? |
||
264 | * |
||
265 | * @return bool |
||
266 | */ |
||
267 | 5 | public function shouldDumpAutoloader() |
|
271 | |||
272 | /** |
||
273 | * Set the optimizeAutoloader flag |
||
274 | * |
||
275 | * @param bool $flag |
||
276 | */ |
||
277 | 105 | public function setOptimizeAutoloader($flag) |
|
281 | |||
282 | /** |
||
283 | * Should the autoloader be optimized? |
||
284 | * |
||
285 | * @return bool |
||
286 | */ |
||
287 | 5 | public function shouldOptimizeAutoloader() |
|
291 | |||
292 | /** |
||
293 | * Add duplicate packages |
||
294 | * |
||
295 | * @param string $type Package type |
||
296 | * @param array $packages |
||
297 | */ |
||
298 | 65 | public function addDuplicateLinks($type, array $packages) |
|
306 | |||
307 | /** |
||
308 | * Get duplicate packages |
||
309 | * |
||
310 | * @param string $type Package type |
||
311 | * @return array |
||
312 | */ |
||
313 | 100 | public function getDuplicateLinks($type) |
|
318 | |||
319 | /** |
||
320 | * Should includes be recursively processed? |
||
321 | * |
||
322 | * @return bool |
||
323 | */ |
||
324 | 100 | public function recurseIncludes() |
|
328 | |||
329 | /** |
||
330 | * Should duplicate links be replaced in a 'last definition wins' order? |
||
331 | * |
||
332 | * @return bool |
||
333 | */ |
||
334 | 40 | public function replaceDuplicateLinks() |
|
338 | |||
339 | /** |
||
340 | * Should the extra section be merged? |
||
341 | * |
||
342 | * By default, the extra section is not merged and there will be many |
||
343 | * cases where the merge of the extra section is performed too late |
||
344 | * to be of use to other plugins. When enabled, merging uses one of |
||
345 | * two strategies - either 'first wins' or 'last wins'. When enabled, |
||
346 | * 'first wins' is the default behaviour. If Replace mode is activated |
||
347 | * then 'last wins' is used. |
||
348 | * |
||
349 | * @return bool |
||
350 | */ |
||
351 | 100 | public function shouldMergeExtra() |
|
355 | |||
356 | /** |
||
357 | * Should the merger prepend repositories to repository manager (instead of adding them to end of the list). |
||
358 | * |
||
359 | * @return bool |
||
360 | */ |
||
361 | 100 | public function shouldPrependRepositories() |
|
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 | * |
||
374 | * This is useful especially for the extra section when plugins use larger |
||
375 | * 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 | 15 | public function shouldMergeExtraDeep() |
|
386 | } |
||
387 | // vim:sw=4:ts=4:sts=4:et: |
||
388 |