1 | <?php namespace Arcanedev\Composer\Entities; |
||
11 | class PluginState |
||
12 | { |
||
13 | /* ------------------------------------------------------------------------------------------------ |
||
14 | | Properties |
||
15 | | ------------------------------------------------------------------------------------------------ |
||
16 | */ |
||
17 | /** @var \Composer\Composer */ |
||
18 | protected $composer; |
||
19 | |||
20 | /** @var array */ |
||
21 | protected $includes = []; |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $requires = []; |
||
25 | |||
26 | /** @var array */ |
||
27 | protected $duplicateLinks = []; |
||
28 | |||
29 | /** @var bool */ |
||
30 | protected $devMode = false; |
||
31 | |||
32 | /** @var bool */ |
||
33 | protected $recurse = true; |
||
34 | |||
35 | /** @var bool */ |
||
36 | protected $replace = false; |
||
37 | |||
38 | /** |
||
39 | * Whether to merge the -dev sections. |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected $mergeDev = true; |
||
44 | |||
45 | /** |
||
46 | * Whether to merge the extra section. |
||
47 | * |
||
48 | * By default, the extra section is not merged and there will be many cases where |
||
49 | * the merge of the extra section is performed too late to be of use to other plugins. |
||
50 | * When enabled, merging uses one of two strategies - either 'first wins' or 'last wins'. |
||
51 | * When enabled, 'first wins' is the default behaviour. If Replace mode is activated |
||
52 | * then 'last wins' is used. |
||
53 | * |
||
54 | * @var bool |
||
55 | */ |
||
56 | protected $mergeExtra = false; |
||
57 | |||
58 | /** @var bool */ |
||
59 | protected $firstInstall = false; |
||
60 | |||
61 | /** @var bool */ |
||
62 | protected $locked = false; |
||
63 | |||
64 | /** @var bool */ |
||
65 | protected $dumpAutoloader = false; |
||
66 | |||
67 | /** @var bool */ |
||
68 | protected $optimizeAutoloader = false; |
||
69 | |||
70 | /** |
||
71 | * Whether to prepend repositories to repository manager. |
||
72 | * |
||
73 | * @var bool |
||
74 | */ |
||
75 | protected $prependRepositories = false; |
||
76 | |||
77 | /* ------------------------------------------------------------------------------------------------ |
||
78 | | Constructor |
||
79 | | ------------------------------------------------------------------------------------------------ |
||
80 | */ |
||
81 | /** |
||
82 | * Make PluginState instance. |
||
83 | * |
||
84 | * @param \Composer\Composer $composer |
||
85 | */ |
||
86 | 135 | public function __construct(Composer $composer) |
|
90 | |||
91 | /* ------------------------------------------------------------------------------------------------ |
||
92 | | Getters & Setters |
||
93 | | ------------------------------------------------------------------------------------------------ |
||
94 | */ |
||
95 | /** |
||
96 | * Get list of filenames and/or glob patterns to include. |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | 100 | public function getIncludes() |
|
104 | |||
105 | /** |
||
106 | * Set the first install flag. |
||
107 | * |
||
108 | * @param bool $flag |
||
109 | * |
||
110 | * @return self |
||
111 | */ |
||
112 | 10 | public function setFirstInstall($flag) |
|
118 | |||
119 | /** |
||
120 | * Is this the first time that the plugin has been installed ? |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | 110 | public function isFirstInstall() |
|
128 | |||
129 | /** |
||
130 | * Set the locked flag. |
||
131 | * |
||
132 | * @param bool $flag |
||
133 | * |
||
134 | * @return self |
||
135 | */ |
||
136 | 15 | public function setLocked($flag) |
|
142 | |||
143 | /** |
||
144 | * Was a lockfile present when the plugin was installed ? |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | 20 | public function isLocked() |
|
152 | |||
153 | /** |
||
154 | * Should an update be forced ? |
||
155 | * |
||
156 | * @return bool |
||
157 | */ |
||
158 | 5 | public function forceUpdate() |
|
162 | |||
163 | /** |
||
164 | * Set the devMode flag. |
||
165 | * |
||
166 | * @param bool $flag |
||
167 | * |
||
168 | * @return self |
||
169 | */ |
||
170 | 100 | public function setDevMode($flag) |
|
176 | |||
177 | /** |
||
178 | * Should devMode settings be processed ? |
||
179 | * |
||
180 | * @return bool |
||
181 | */ |
||
182 | 95 | public function isDevMode() |
|
186 | |||
187 | /** |
||
188 | * Set the dumpAutoloader flag. |
||
189 | * |
||
190 | * @param bool $flag |
||
191 | * |
||
192 | * @return self |
||
193 | */ |
||
194 | 100 | public function setDumpAutoloader($flag) |
|
200 | |||
201 | /** |
||
202 | * Is the autoloader file supposed to be written out ? |
||
203 | * |
||
204 | * @return bool |
||
205 | */ |
||
206 | 5 | public function shouldDumpAutoloader() |
|
210 | |||
211 | /** |
||
212 | * Set the optimizeAutoloader flag. |
||
213 | * |
||
214 | * @param bool $flag |
||
215 | * |
||
216 | * @return self |
||
217 | */ |
||
218 | 100 | public function setOptimizeAutoloader($flag) |
|
224 | |||
225 | /** |
||
226 | * Should the autoloader be optimized ? |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | 5 | public function shouldOptimizeAutoloader() |
|
234 | |||
235 | /** |
||
236 | * Should the merger prepend repositories to repository manager (instead of adding them to end of the list). |
||
237 | * |
||
238 | * @return bool |
||
239 | */ |
||
240 | 95 | public function shouldPrependRepositories() |
|
244 | |||
245 | /** |
||
246 | * Add duplicate packages. |
||
247 | * |
||
248 | * @param string $type |
||
249 | * @param array $packages |
||
250 | * |
||
251 | * @return self |
||
252 | */ |
||
253 | 60 | public function addDuplicateLinks($type, array $packages) |
|
266 | |||
267 | /** |
||
268 | * Should includes be recursively processed ? |
||
269 | * |
||
270 | * @return bool |
||
271 | */ |
||
272 | 95 | public function recurseIncludes() |
|
276 | |||
277 | /** |
||
278 | * Get list of filenames and/or glob patterns to require |
||
279 | * |
||
280 | * @return array |
||
281 | */ |
||
282 | 100 | public function getRequires() |
|
286 | |||
287 | /** |
||
288 | * Get duplicate packages. |
||
289 | * |
||
290 | * @param string $type |
||
291 | * |
||
292 | * @return array |
||
293 | */ |
||
294 | 95 | public function getDuplicateLinks($type) |
|
300 | |||
301 | /** |
||
302 | * Should duplicate links be replaced in a 'last definition wins' order ? |
||
303 | * |
||
304 | * @return bool |
||
305 | */ |
||
306 | 75 | public function replaceDuplicateLinks() |
|
310 | |||
311 | /** |
||
312 | * Should the extra section be merged ? |
||
313 | * |
||
314 | * By default, the extra section is not merged and there will be many cases where |
||
315 | * the merge of the extra section is performed too late to be of use to other plugins. |
||
316 | * When enabled, merging uses one of two strategies - either 'first wins' or 'last wins'. |
||
317 | * When enabled, 'first wins' is the default behaviour. If Replace mode is activated |
||
318 | * then 'last wins' is used. |
||
319 | * |
||
320 | * @return bool |
||
321 | */ |
||
322 | 95 | public function shouldMergeExtra() |
|
326 | |||
327 | /* ------------------------------------------------------------------------------------------------ |
||
328 | | Main Functions |
||
329 | | ------------------------------------------------------------------------------------------------ |
||
330 | */ |
||
331 | /** |
||
332 | * Load plugin settings. |
||
333 | */ |
||
334 | 100 | public function loadSettings() |
|
347 | |||
348 | /* ------------------------------------------------------------------------------------------------ |
||
349 | | Other Functions |
||
350 | | ------------------------------------------------------------------------------------------------ |
||
351 | */ |
||
352 | /** |
||
353 | * Merge config. |
||
354 | * |
||
355 | * @param array $extra |
||
356 | * |
||
357 | * @return array |
||
358 | */ |
||
359 | 100 | private function mergeConfig(array $extra) |
|
374 | } |
||
375 |