1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
11
|
|
|
|
12
|
|
|
class Fifree2installCommand extends ContainerAwareCommand |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
protected $fixtureFile; |
16
|
|
|
|
17
|
3 |
|
protected function configure() |
18
|
|
|
{ |
19
|
|
|
$this |
20
|
3 |
|
->setName('fifree2:install') |
21
|
3 |
|
->setDescription('Installazione ambiente fifree') |
22
|
3 |
|
->setHelp('Crea il database, un utente amministratore e i dati di default') |
23
|
3 |
|
->addArgument('admin', InputArgument::REQUIRED, 'Username per amministratore') |
24
|
3 |
|
->addArgument('adminpass', InputArgument::REQUIRED, 'Password per amministratore') |
25
|
3 |
|
->addArgument('adminemail', InputArgument::REQUIRED, 'Email per amministratore') |
26
|
|
|
; |
27
|
3 |
|
} |
28
|
|
|
|
29
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
30
|
|
|
{ |
31
|
1 |
|
$admin = $input->getArgument('admin'); |
|
|
|
|
32
|
1 |
|
$adminpass = $input->getArgument('adminpass'); |
|
|
|
|
33
|
1 |
|
$adminemail = $input->getArgument('adminemail'); |
|
|
|
|
34
|
1 |
|
$this->fixtureFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fixtures.yml'; |
35
|
|
|
|
36
|
1 |
|
if (!$admin) { |
37
|
|
|
echo "Inserire il nome utente dell'amministratore"; |
38
|
|
|
|
39
|
|
|
return 1; |
40
|
|
|
} |
41
|
1 |
|
if (!$adminpass) { |
42
|
|
|
echo "Inserire la password per dell'amministratore"; |
43
|
|
|
|
44
|
|
|
return 1; |
45
|
|
|
} |
46
|
1 |
|
if (!$adminemail) { |
47
|
|
|
echo "Inserire la mail dell'amministratore"; |
48
|
|
|
|
49
|
|
|
return 1; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
$commanddb = $this->getApplication()->find('fifree2:createdatabase'); |
|
|
|
|
53
|
1 |
|
$argumentsdb = array('command' => 'fifree2:createdatabase'); |
54
|
1 |
|
$inputc = new ArrayInput($argumentsdb); |
|
|
|
|
55
|
1 |
|
$commanddb->run($inputc, $output); |
56
|
|
|
|
57
|
1 |
|
$this->generateDefaultData($admin, $adminemail); |
58
|
|
|
|
59
|
1 |
|
$commanddata = $this->getApplication()->find('fifree2:configuratorimport'); |
|
|
|
|
60
|
|
|
$argumentsdata = array( |
61
|
1 |
|
'command' => 'fifree2:configuratorimport', |
62
|
|
|
array("--truncatetables" => true) |
|
|
|
|
63
|
|
|
); |
64
|
1 |
|
$inputd = new ArrayInput($argumentsdata); |
|
|
|
|
65
|
1 |
|
$commanddata->run($inputd, $output); |
66
|
|
|
|
67
|
1 |
|
$fs = new Filesystem(); |
68
|
1 |
|
$fs->remove($this->fixtureFile); |
69
|
|
|
|
70
|
1 |
|
$userManipulator = $this->getContainer()->get('fi.corebundle.fos_user.util.user_manipulator'); |
71
|
|
|
|
72
|
1 |
|
$userManipulator->changePassword($admin, $adminpass); |
73
|
1 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* This will suppress UnusedLocalVariable |
77
|
|
|
* warnings in this method |
78
|
|
|
* |
79
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) |
80
|
|
|
*/ |
81
|
1 |
|
private function generateDefaultData($admin, $adminemail) |
82
|
|
|
{ |
83
|
|
|
//$todaydt = new \DateTime(); |
|
|
|
|
84
|
|
|
//$today = $todaydt->format("Y-m-d") . "T00:00:00+01:00"; |
|
|
|
|
85
|
|
|
|
86
|
|
|
$defaultData = <<<EOF |
87
|
|
|
Fi\CoreBundle\Entity\Ruoli: |
88
|
|
|
- |
89
|
|
|
id: 1 |
90
|
|
|
ruolo: 'Super Admin' |
91
|
|
|
paginainiziale: /adminpanel |
92
|
|
|
superadmin: true |
93
|
|
|
admin: true |
94
|
|
|
user: false |
95
|
|
|
- |
96
|
|
|
id: 2 |
97
|
|
|
ruolo: Amministratore |
98
|
|
|
paginainiziale: /adminpanel |
99
|
|
|
superadmin: false |
100
|
|
|
admin: true |
101
|
|
|
user: false |
102
|
|
|
- |
103
|
|
|
id: 3 |
104
|
|
|
ruolo: Utente |
105
|
|
|
paginainiziale: / |
106
|
|
|
superadmin: false |
107
|
|
|
admin: false |
108
|
|
|
user: true |
109
|
|
|
Fi\CoreBundle\Entity\Operatori: |
110
|
|
|
- |
111
|
1 |
|
username: $admin |
112
|
1 |
|
usernameCanonical: $admin |
113
|
1 |
|
email: $adminemail |
114
|
1 |
|
emailCanonical: $adminemail |
115
|
|
|
enabled: true |
116
|
|
|
salt: null |
117
|
1 |
|
password: $admin |
118
|
|
|
lastLogin: null |
119
|
|
|
confirmationToken: null |
120
|
|
|
passwordRequestedAt: null |
121
|
|
|
roles: |
122
|
|
|
- ROLE_SUPER_ADMIN |
123
|
|
|
id: 1 |
124
|
1 |
|
operatore: $admin |
125
|
|
|
ruoli_id: 1 |
126
|
|
|
- |
127
|
|
|
username: userreadroles |
128
|
|
|
usernameCanonical: userreadroles |
129
|
|
|
email: [email protected] |
130
|
|
|
emailCanonical: [email protected] |
131
|
|
|
enabled: true |
132
|
|
|
salt: mNVzoSgms1k9JU2Eb/syehddayryUqNDh0LFzjggcCM |
133
|
|
|
password: 1yNtksQ2XpN+zj/Jk9IP0MpBZcaBxg0nltY+EML4Vlv3cJ8g6U6/YaejAP+tagemH2N2htTqP7tELs2ZhlRAHw== |
134
|
|
|
lastLogin: null |
135
|
|
|
confirmationToken: null |
136
|
|
|
passwordRequestedAt: null |
137
|
|
|
roles: { } |
138
|
|
|
id: 2 |
139
|
|
|
operatore: null |
140
|
|
|
ruoli_id: 3 |
141
|
|
|
- |
142
|
|
|
username: usernoroles |
143
|
|
|
usernameCanonical: usernoroles |
144
|
|
|
email: [email protected] |
145
|
|
|
emailCanonical: [email protected] |
146
|
|
|
enabled: true |
147
|
|
|
salt: nczIukArDyAEH6vvjehM973qvfDjE.WGzkP24umtpfE |
148
|
|
|
password: Ce0FJ16dd5HfwJ8CbzocZB3UDZWzwvD9l/A3kyJJR1oHoisxGjF06qR4sSj/Nsk8J6aCI1GtgmHbJfeF7TS93w== |
149
|
|
|
lastLogin: null |
150
|
|
|
confirmationToken: null |
151
|
|
|
passwordRequestedAt: null |
152
|
|
|
roles: { } |
153
|
|
|
id: 3 |
154
|
|
|
operatore: null |
155
|
|
|
ruoli_id: 3 |
156
|
|
|
Fi\CoreBundle\Entity\Permessi: |
157
|
|
|
- |
158
|
|
|
id: 1 |
159
|
|
|
modulo: Menuapplicazione |
160
|
|
|
crud: crud |
161
|
|
|
operatori_id: null |
162
|
|
|
ruoli_id: 1 |
163
|
|
|
- |
164
|
|
|
id: 2 |
165
|
|
|
modulo: Opzionitabella |
166
|
|
|
crud: crud |
167
|
|
|
operatori_id: null |
168
|
|
|
ruoli_id: 1 |
169
|
|
|
- |
170
|
|
|
id: 3 |
171
|
|
|
modulo: Tabelle |
172
|
|
|
crud: crud |
173
|
|
|
operatori_id: null |
174
|
|
|
ruoli_id: 1 |
175
|
|
|
- |
176
|
|
|
id: 4 |
177
|
|
|
modulo: Permessi |
178
|
|
|
crud: crud |
179
|
|
|
operatori_id: null |
180
|
|
|
ruoli_id: 1 |
181
|
|
|
- |
182
|
|
|
id: 5 |
183
|
|
|
modulo: Operatori |
184
|
|
|
crud: cru |
185
|
|
|
operatori_id: null |
186
|
|
|
ruoli_id: 1 |
187
|
|
|
- |
188
|
|
|
id: 6 |
189
|
|
|
modulo: Ruoli |
190
|
|
|
crud: crud |
191
|
|
|
operatori_id: null |
192
|
|
|
ruoli_id: 2 |
193
|
|
|
- |
194
|
|
|
id: 7 |
195
|
|
|
modulo: Cliente |
196
|
|
|
crud: crud |
197
|
|
|
operatori_id: null |
198
|
|
|
ruoli_id: 2 |
199
|
|
|
- |
200
|
|
|
id: 8 |
201
|
|
|
modulo: Fornitore |
202
|
|
|
crud: crud |
203
|
|
|
operatori_id: null |
204
|
|
|
ruoli_id: 2 |
205
|
|
|
- |
206
|
|
|
id: 9 |
207
|
|
|
modulo: Prodottofornitore |
208
|
|
|
crud: crud |
209
|
|
|
operatori_id: null |
210
|
|
|
ruoli_id: 2 |
211
|
|
|
- |
212
|
|
|
id: 10 |
213
|
|
|
modulo: Ordine |
214
|
|
|
crud: crud |
215
|
|
|
operatori_id: null |
216
|
|
|
ruoli_id: 2 |
217
|
|
|
- |
218
|
|
|
id: 11 |
219
|
|
|
modulo: Ordine |
220
|
|
|
crud: crud |
221
|
|
|
operatori_id: null |
222
|
|
|
ruoli_id: 2 |
223
|
|
|
- |
224
|
|
|
id: 12 |
225
|
|
|
modulo: Magazzino |
226
|
|
|
crud: r |
227
|
|
|
operatori_id: 2 |
228
|
|
|
ruoli_id: null |
229
|
|
|
|
230
|
|
|
Fi\CoreBundle\Entity\Colonnetabelle: |
231
|
|
|
- |
232
|
|
|
id: 1 |
233
|
|
|
nometabella: '*' |
234
|
|
|
nomecampo: null |
235
|
|
|
mostraindex: null |
236
|
|
|
ordineindex: null |
237
|
|
|
larghezzaindex: null |
238
|
|
|
etichettaindex: null |
239
|
|
|
mostrastampa: null |
240
|
|
|
ordinestampa: null |
241
|
|
|
larghezzastampa: null |
242
|
|
|
operatori_id: null |
243
|
|
|
registrastorico: null |
244
|
|
|
- |
245
|
|
|
id: 2 |
246
|
|
|
nometabella: Permessi |
247
|
|
|
nomecampo: modulo |
248
|
|
|
mostraindex: true |
249
|
|
|
ordineindex: 20 |
250
|
|
|
larghezzaindex: 100 |
251
|
|
|
etichettaindex: Modulo |
252
|
|
|
mostrastampa: true |
253
|
|
|
ordinestampa: 20 |
254
|
|
|
larghezzastampa: 100 |
255
|
|
|
operatori_id: null |
256
|
|
|
registrastorico: true |
257
|
|
|
- |
258
|
|
|
id: 3 |
259
|
|
|
nometabella: Permessi |
260
|
|
|
nomecampo: crud |
261
|
|
|
mostraindex: true |
262
|
|
|
ordineindex: 30 |
263
|
|
|
larghezzaindex: 100 |
264
|
|
|
etichettaindex: CRUD |
265
|
|
|
mostrastampa: true |
266
|
|
|
ordinestampa: 30 |
267
|
|
|
larghezzastampa: 100 |
268
|
|
|
operatori_id: null |
269
|
|
|
registrastorico: true |
270
|
|
|
- |
271
|
|
|
id: 4 |
272
|
|
|
nometabella: Permessi |
273
|
|
|
nomecampo: ruoli |
274
|
|
|
mostraindex: true |
275
|
|
|
ordineindex: 50 |
276
|
|
|
larghezzaindex: 100 |
277
|
|
|
etichettaindex: Ruolo |
278
|
|
|
mostrastampa: true |
279
|
|
|
ordinestampa: 50 |
280
|
|
|
larghezzastampa: 100 |
281
|
|
|
operatori_id: null |
282
|
|
|
registrastorico: true |
283
|
|
|
- |
284
|
|
|
id: 5 |
285
|
|
|
nometabella: Permessi |
286
|
|
|
nomecampo: operatori |
287
|
|
|
mostraindex: true |
288
|
|
|
ordineindex: 60 |
289
|
|
|
larghezzaindex: 100 |
290
|
|
|
etichettaindex: Operatore |
291
|
|
|
mostrastampa: true |
292
|
|
|
ordinestampa: 60 |
293
|
|
|
larghezzastampa: 100 |
294
|
|
|
operatori_id: null |
295
|
|
|
registrastorico: true |
296
|
|
|
|
297
|
|
|
Fi\CoreBundle\Entity\Opzionitabelle: |
298
|
|
|
- |
299
|
|
|
id: 1 |
300
|
|
|
nometabella: '*' |
301
|
|
|
descrizione: null |
302
|
|
|
parametro: titolo |
303
|
|
|
valore: 'Elenco dati per %tabella%' |
304
|
|
|
- |
305
|
|
|
id: 2 |
306
|
|
|
nometabella: '*' |
307
|
|
|
descrizione: 'Altezza Griglia' |
308
|
|
|
parametro: altezzagriglia |
309
|
|
|
valore: '400' |
310
|
|
|
|
311
|
|
|
Fi\CoreBundle\Entity\Menuapplicazione: |
312
|
|
|
- |
313
|
|
|
id: 1 |
314
|
|
|
nome: Amministrazione |
315
|
|
|
percorso: null |
316
|
|
|
padre: null |
317
|
|
|
ordine: 20 |
318
|
|
|
attivo: true |
319
|
|
|
target: null |
320
|
|
|
tag: null |
321
|
|
|
notifiche: null |
322
|
|
|
autorizzazionerichiesta: null |
323
|
|
|
percorsonotifiche: null |
324
|
|
|
- |
325
|
|
|
id: 2 |
326
|
|
|
nome: Operatori |
327
|
|
|
percorso: Operatori |
328
|
|
|
padre: 1 |
329
|
|
|
ordine: 10 |
330
|
|
|
attivo: true |
331
|
|
|
target: null |
332
|
|
|
tag: null |
333
|
|
|
notifiche: null |
334
|
|
|
autorizzazionerichiesta: null |
335
|
|
|
percorsonotifiche: null |
336
|
|
|
- |
337
|
|
|
id: 3 |
338
|
|
|
nome: Ruoli |
339
|
|
|
percorso: Ruoli |
340
|
|
|
padre: 1 |
341
|
|
|
ordine: 20 |
342
|
|
|
attivo: true |
343
|
|
|
target: null |
344
|
|
|
tag: null |
345
|
|
|
notifiche: null |
346
|
|
|
autorizzazionerichiesta: null |
347
|
|
|
percorsonotifiche: null |
348
|
|
|
- |
349
|
|
|
id: 4 |
350
|
|
|
nome: Permessi |
351
|
|
|
percorso: Permessi |
352
|
|
|
padre: 1 |
353
|
|
|
ordine: 30 |
354
|
|
|
attivo: true |
355
|
|
|
target: null |
356
|
|
|
tag: null |
357
|
|
|
notifiche: null |
358
|
|
|
autorizzazionerichiesta: null |
359
|
|
|
percorsonotifiche: null |
360
|
|
|
- |
361
|
|
|
id: 5 |
362
|
|
|
nome: 'Gestione tabelle di sistema' |
363
|
|
|
percorso: null |
364
|
|
|
padre: 1 |
365
|
|
|
ordine: 40 |
366
|
|
|
attivo: true |
367
|
|
|
target: null |
368
|
|
|
tag: null |
369
|
|
|
notifiche: null |
370
|
|
|
autorizzazionerichiesta: null |
371
|
|
|
percorsonotifiche: null |
372
|
|
|
- |
373
|
|
|
id: 6 |
374
|
|
|
nome: 'Colonne tabelle' |
375
|
|
|
percorso: Colonnetabelle |
376
|
|
|
padre: 5 |
377
|
|
|
ordine: 10 |
378
|
|
|
attivo: true |
379
|
|
|
target: null |
380
|
|
|
tag: null |
381
|
|
|
notifiche: null |
382
|
|
|
autorizzazionerichiesta: null |
383
|
|
|
percorsonotifiche: null |
384
|
|
|
- |
385
|
|
|
id: 7 |
386
|
|
|
nome: 'Opzioni tabelle' |
387
|
|
|
percorso: Opzionitabelle |
388
|
|
|
padre: 5 |
389
|
|
|
ordine: 20 |
390
|
|
|
attivo: true |
391
|
|
|
target: null |
392
|
|
|
tag: null |
393
|
|
|
notifiche: null |
394
|
|
|
autorizzazionerichiesta: null |
395
|
|
|
percorsonotifiche: null |
396
|
|
|
- |
397
|
|
|
id: 8 |
398
|
|
|
nome: 'Menu Applicazione' |
399
|
|
|
percorso: Menuapplicazione |
400
|
|
|
padre: 1 |
401
|
|
|
ordine: 50 |
402
|
|
|
attivo: true |
403
|
|
|
target: null |
404
|
|
|
tag: null |
405
|
|
|
notifiche: null |
406
|
|
|
autorizzazionerichiesta: null |
407
|
|
|
percorsonotifiche: null |
408
|
|
|
- |
409
|
|
|
id: 9 |
410
|
|
|
nome: Utilità |
411
|
|
|
percorso: fi_pannello_amministrazione_homepage |
412
|
|
|
padre: 1 |
413
|
|
|
ordine: 100 |
414
|
|
|
attivo: true |
415
|
|
|
target: null |
416
|
|
|
tag: null |
417
|
|
|
notifiche: null |
418
|
|
|
autorizzazionerichiesta: null |
419
|
|
|
percorsonotifiche: null |
420
|
|
|
EOF; |
421
|
1 |
|
$fs = new Filesystem(); |
|
|
|
|
422
|
1 |
|
$fs->dumpFile($this->fixtureFile, $defaultData); |
423
|
1 |
|
} |
424
|
|
|
} |
425
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.