BiCoreBundleDropdatabaseCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\ArrayInput;
10
11
class BiCoreBundleDropdatabaseCommand extends Command
12
{
13
    protected static $defaultName = 'bicorebundle:dropdatabase';
14
15 1
    protected function configure(): void
16
    {
17 1
        $this
18 1
                ->setDescription('Cancellazione database bicorebundle')
19 1
                ->setHelp('Cancella il database e tutti i dati di bicorebundle')
20 1
                ->addOption('force', null, InputOption::VALUE_NONE, 'Se non impostato, il comando non avrà effetto');
21
    }
22
23 1
    protected function execute(InputInterface $input, OutputInterface $output): int
24
    {
25 1
        $force = $input->getOption('force');
26
27 1
        if (!$force) {
28
            echo "Specificare l'opzione --force per eseguire il comando";
29
30
            return 1;
31
        }
32
33
        /*$command = $this->getApplication()->find('doctrine:database:drop');
34
        $arguments = array('command' => 'doctrine:database:drop', '--force' => true, '--if-exists' => true);
35
        $inputcmd = new ArrayInput($arguments);
36
        $command->run($inputcmd, $output);*/
37
38 1
        $command = $this->getApplication()->find('doctrine:schema:drop');
39 1
        $arguments = array('command' => 'doctrine:schema:drop', '--force' => true, '--full-database' => true);
40 1
        $inputcmd = new ArrayInput($arguments);
41 1
        $command->run($inputcmd, $output);
42 1
        return 0;
43
    }
44
}
45