Passed
Push — master ( ce89ba...4bc45e )
by Andrea
11:12
created

Fifree2installCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 489
Duplicated Lines 0 %

Test Coverage

Coverage 90.48%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 489
ccs 57
cts 63
cp 0.9048
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 1
B execute() 0 44 4
B generateDefaultData() 0 420 1
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 3
        $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');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 13 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32 1
        $adminpass = $input->getArgument('adminpass');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
33 1
        $adminemail = $input->getArgument('adminemail');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
53 1
        $argumentsdb = array('command' => 'fifree2:createdatabase');
54 1
        $inputc = new ArrayInput($argumentsdb);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
55 1
        $commanddb->run($inputc, $output);
56
57 1
        $this->generateDefaultData($admin, $adminemail);
58
59 1
        $commanddata = $this->getApplication()->find('fifree2:configuratorimport');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
60
        $argumentsdata = array(
61 1
            'command' => 'fifree2:configuratorimport',
62 1
            array("--truncatetables" => true)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal --truncatetables does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
63 1
        );
64 1
        $inputd = new ArrayInput($argumentsdata);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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('fifree.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 1
        $todaydt = new \DateTime();
84 1
        $today = $todaydt->format("Y-m-d") . "T00:00:00+01:00";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Y-m-d does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal T00:00:00+01:00 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
85
        
86
        $defaultData = <<<EOF
87
Fi\CoreBundle\Entity\Ruoli:
88
  -
89
    id: 1
90
    ruolo: 'Super Admin'
91
    paginainiziale: /adminpanel
92
    is_superadmin: true
93
    is_admin: true
94
    is_user: false
95
  -
96
    id: 2
97
    ruolo: Amministratore
98
    paginainiziale: /adminpanel
99
    is_superadmin: false
100
    is_admin: true
101
    is_user: false
102
  -
103
    id: 3
104
    ruolo: Utente
105
    paginainiziale: /ffprincipale
106
    is_superadmin: false
107
    is_admin: false
108
    is_user: true
109
Fi\CoreBundle\Entity\Operatori:
110
  -
111
    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
Fi\CoreBundle\Entity\Permessi:
127
  -
128
    id: 1
129 1
    modulo: MenuApplicazione
130 1
    crud: crud
131
    operatori_id: null
132
    ruoli_id: 1
133
  -
134
    id: 2
135
    modulo: OpzioniTabella
136
    crud: crud
137
    operatori_id: null
138
    ruoli_id: 1
139
  -
140
    id: 3
141
    modulo: Tabelle
142
    crud: crud
143
    operatori_id: null
144
    ruoli_id: 1
145
  -
146
    id: 4
147
    modulo: Permessi
148
    crud: crud
149
    operatori_id: null
150
    ruoli_id: 1
151
  -
152
    id: 5
153
    modulo: Operatori
154
    crud: cru
155
    operatori_id: null
156
    ruoli_id: 1
157
  -
158
    id: 6
159
    modulo: Ruoli
160
    crud: crud
161
    operatori_id: null
162
    ruoli_id: 1
163
  -
164
    id: 7
165
    modulo: Ffprincipale
166
    crud: crud
167
    operatori_id: null
168
    ruoli_id: 1
169
  -
170
    id: 8
171
    modulo: Ffsecondaria
172
    crud: crud
173
    operatori_id: null
174
    ruoli_id: 1
175
Fi\CoreBundle\Entity\Tabelle:
176
  -
177
    id: 1
178
    nometabella: '*'
179
    nomecampo: null
180
    mostraindex: null
181
    ordineindex: null
182
    larghezzaindex: null
183
    etichettaindex: null
184
    mostrastampa: null
185
    ordinestampa: null
186
    larghezzastampa: null
187
    etichettastampa: null
188
    operatori_id: null
189
    registrastorico: null
190
  -
191
    id: 2
192
    nometabella: Ffsecondaria
193
    nomecampo: ffprincipale
194
    mostraindex: true
195
    ordineindex: null
196
    larghezzaindex: null
197
    etichettaindex: null
198
    mostrastampa: true
199
    ordinestampa: null
200
    larghezzastampa: null
201
    etichettastampa: null
202
    operatori_id: null
203
    registrastorico: true
204
  -
205
    id: 3
206
    nometabella: Ffsecondaria
207
    nomecampo: descsec
208
    mostraindex: true
209
    ordineindex: null
210
    larghezzaindex: null
211
    etichettaindex: null
212
    mostrastampa: true
213
    ordinestampa: null
214
    larghezzastampa: null
215
    etichettastampa: null
216
    operatori_id: null
217
    registrastorico: true
218
Fi\CoreBundle\Entity\OpzioniTabella:
219
  -
220
    id: 1
221
    tabelle_id: 1
222
    descrizione: null
223
    parametro: titolo
224
    valore: 'Elenco dati per %tabella%'
225
  -
226
    id: 2
227
    tabelle_id: 1
228
    descrizione: 'Altezza Griglia'
229
    parametro: altezzagriglia
230
    valore: '400'
231
  -
232
    id: 3
233
    tabelle_id: 1
234
    descrizione: 'Esegue filtri con invio in testata griglia'
235
    parametro: filterToolbar_searchOnEnter
236
    valore: true
237
  -
238
    id: 4
239
    tabelle_id: 1
240
    descrizione: 'Aggiunge filtri di default in testata griglia'
241
    parametro: filterToolbar_searchOperators
242
    valore: true
243
Fi\CoreBundle\Entity\Ffprincipale:
244
  -
245
    id: 1
246
    descrizione: 'Descrizione primo record'
247
  -
248
    id: 2
249
    descrizione: 'Descrizione secondo record'
250
Fi\CoreBundle\Entity\Ffsecondaria:
251
  -
252
    id: 1
253
    descsec: '1° secondaria legato al 1° record PRINCIPALE'
254
    ffprincipale_id: 1
255 1
    data: $today
256
    intero: 10
257
    importo: 12.34
258
    nota: 'Super Nota ffsecondaria'
259
    attivo: true
260
  -
261
    id: 2
262
    descsec: '2° SECONDARIA legato al 1° record principale'
263
    ffprincipale_id: 1
264 1
    data: $today
265
    intero: 1
266
    importo: 1.23
267
    nota: 'Nota ffsecondaria'
268
    attivo: true
269
  -
270
    id: 3
271
    descsec: '3° secondaria legato al 1° record principale'
272
    ffprincipale_id: 1
273 1
    data: $today
274
    intero: 10
275
    importo: 11.34
276
    nota: 'Nota 3° ffsecondaria'
277
    attivo: false
278
  -
279
    id: 4
280
    descsec: '4° Secondaria legato al 1° record Principale'
281
    ffprincipale_id: 1
282 1
    data: $today
283
    intero: 101
284
    importo: 101.34
285
    nota: 'Nota 4° ffsecondaria'
286
    attivo: true
287
  -
288
    id: 5
289
    descsec: '5° secondaria legato al 1° record principale'
290
    ffprincipale_id: 1
291 1
    data: $today
292
    intero: 101
293
    importo: 101.34
294
    nota: 'Nota 4° ffsecondaria'
295
    attivo: true
296
  -
297
    id: 6
298
    descsec: '6° secondaria legato al 2° record principale'
299
    ffprincipale_id: 2
300 1
    data: $today
301
    intero: 10006
302
    importo: 10006.12
303
    nota: 'Nota altra ffsecondaria'
304
    attivo: true
305
  -
306
    id: 7
307
    descsec: '7° secondaria legato al 2° record principale'
308
    ffprincipale_id: 2
309 1
    data: $today
310
    intero: 10007
311
    importo: 10007.22
312
    nota: 'Nota altra 7 ffsecondaria'
313
    attivo: false
314
  -
315
    id: 8
316
    descsec: null
317
    ffprincipale_id: 2
318 1
    data: $today
319
    intero: 1111
320
    importo: 1111.12
321
    nota: 'Nota ffsecondaria con descsec null'
322
    attivo: false
323
  -
324
    id: 9
325
    descsec: '9° secondaria legato al 2° "record principale"'
326
    ffprincipale_id: 2
327 1
    data: $today
328
    intero: 1000
329
    importo: 1000.12
330
    nota: 'Nota altra ffsecondaria'
331
    attivo: true
332
  -
333
    id: 10
334
    descsec: '10° secondaria legato al 2° record principale ed è l''ultimo record'
335
    ffprincipale_id: 2
336 1
    data: $today
337
    intero: 1100
338
    importo: 1100.99
339
    nota: 'Nota 10° altra ffsecondaria'
340
    attivo: false
341
Fi\CoreBundle\Entity\MenuApplicazione:
342
  -
343
    id: 1
344
    nome: Tabelle
345
    percorso: null
346
    padre: null
347
    ordine: 10
348
    attivo: true
349
    target: null
350
    tag: null
351
    notifiche: null
352
    autorizzazionerichiesta: null
353
    percorsonotifiche: null
354
  -
355
    id: 2
356
    nome: FFprincipale
357
    percorso: Ffprincipale
358
    padre: 1
359
    ordine: 10
360
    attivo: true
361
    target: null
362
    tag: null
363
    notifiche: null
364
    autorizzazionerichiesta: null
365
    percorsonotifiche: null
366
  -
367
    id: 3
368
    nome: FFsecondaria
369
    percorso: Ffsecondaria
370
    padre: 1
371
    ordine: 10
372
    attivo: true
373
    target: null
374
    tag: null
375
    notifiche: null
376
    autorizzazionerichiesta: null
377
    percorsonotifiche: null
378
  -
379
    id: 4
380
    nome: Amministrazione
381
    percorso: null
382
    padre: null
383
    ordine: 20
384
    attivo: true
385
    target: null
386
    tag: null
387
    notifiche: null
388
    autorizzazionerichiesta: null
389
    percorsonotifiche: null
390
  -
391
    id: 5
392
    nome: Operatori
393
    percorso: Operatori
394
    padre: 4
395
    ordine: 10
396
    attivo: true
397
    target: null
398
    tag: null
399
    notifiche: null
400
    autorizzazionerichiesta: null
401
    percorsonotifiche: null
402
  -
403
    id: 6
404
    nome: Ruoli
405
    percorso: Ruoli
406
    padre: 4
407
    ordine: 20
408
    attivo: true
409
    target: null
410
    tag: null
411
    notifiche: null
412
    autorizzazionerichiesta: null
413
    percorsonotifiche: null
414
  -
415
    id: 7
416
    nome: Permessi
417
    percorso: Permessi
418
    padre: 4
419
    ordine: 30
420
    attivo: true
421
    target: null
422
    tag: null
423
    notifiche: null
424
    autorizzazionerichiesta: null
425
    percorsonotifiche: null
426
  -
427
    id: 8
428
    nome: 'Gestione tabelle'
429
    percorso: null
430
    padre: 4
431
    ordine: 40
432
    attivo: true
433
    target: null
434
    tag: null
435
    notifiche: null
436
    autorizzazionerichiesta: null
437
    percorsonotifiche: null
438
  -
439
    id: 9
440
    nome: Tabelle
441
    percorso: Tabelle
442
    padre: 8
443
    ordine: 10
444
    attivo: true
445
    target: null
446
    tag: null
447
    notifiche: null
448
    autorizzazionerichiesta: null
449
    percorsonotifiche: null
450
  -
451
    id: 10
452
    nome: 'Opzioni tabella'
453
    percorso: OpzioniTabella
454
    padre: 8
455
    ordine: 20
456
    attivo: true
457
    target: null
458
    tag: null
459
    notifiche: null
460
    autorizzazionerichiesta: null
461
    percorsonotifiche: null
462
  -
463
    id: 11
464
    nome: 'Menu Applicazione'
465
    percorso: MenuApplicazione_container
466
    padre: 4
467
    ordine: 50
468
    attivo: true
469
    target: null
470
    tag: null
471
    notifiche: null
472
    autorizzazionerichiesta: null
473
    percorsonotifiche: null
474
  -
475
    id: 12
476
    nome: Utilità
477
    percorso: fi_pannello_amministrazione_homepage
478
    padre: 4
479
    ordine: 100
480
    attivo: true
481
    target: null
482
    tag: null
483
    notifiche: null
484
    autorizzazionerichiesta: null
485
    percorsonotifiche: null
486
  -
487
    id: 13
488
    nome: FiDemo
489
    percorso: fi_demo_index
490
    padre: 4
491
    ordine: 150
492
    attivo: false
493
    target: null
494
    tag: null
495
    notifiche: null
496
    autorizzazionerichiesta: null
497 1
    percorsonotifiche: null
498 1
EOF;
499 1
        $fs = new Filesystem();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
500 1
        $fs->dumpFile($this->fixtureFile, $defaultData);
501 1
    }
502
}
503