Completed
Push — feature/EVO-4597-rabbitmq-hand... ( 6e503b...616297 )
by
unknown
52:22 queued 46:35
created

CleanDynamicBundleCacheCommand::setKernel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * cleans dynamic bundle directory
4
 */
5
6
namespace Graviton\GeneratorBundle\Command;
7
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\Output;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Process\Process;
14
15
/**
16
 * Deletes the GravitonDyn/ folder..
17
 *
18
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
19
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
20
 * @link     http://swisscom.ch
21
 */
22
class CleanDynamicBundleCacheCommand extends Command
23
{
24
25
    /**
26
     * kernel
27
     *
28
     * @var \Graviton\AppKernel
29
     */
30
    private $kernel;
31
32
    /**
33
     * filesystem
34
     *
35
     * @var \Symfony\Component\Filesystem\Filesystem
36
     */
37
    private $filesystem;
38
39
    /**
40
     * {@inheritDoc}
41
     *
42
     * @return void
43
     */
44 1
    protected function configure()
45
    {
46 1
        parent::configure();
47
48 1
        $this->setName('graviton:clean:dynamicbundles')
49 1
             ->setDescription(
50
                 'Removes the folder with the generated dynamic bundles'
51 1
             );
52 1
    }
53
54
    /**
55
     * set kernel
56
     *
57
     * @param mixed $kernel kernel
58
     *
59
     * @return void
60
     */
61 1
    public function setKernel($kernel)
62
    {
63 1
        $this->kernel = $kernel;
64 1
    }
65
66
    /**
67
     * set filesystem
68
     *
69
     * @param mixed $filesystem filesystem
70
     *
71
     * @return void
72
     */
73 1
    public function setFilesystem($filesystem)
74
    {
75 1
        $this->filesystem = $filesystem;
76 1
    }
77
78
    /**
79
     * {@inheritDoc}
80
     *
81
     * @param InputInterface  $input  input
82
     * @param OutputInterface $output output
83
     *
84
     * @return void
85
     */
86 1
    protected function execute(InputInterface $input, OutputInterface $output)
87
    {
88
        // @todo it was suggested this may/should be moved to app/cache..?
89 1
        $dynamicDir = $this->kernel->getRootDir().'/../src/GravitonDyn/';
90
91 1
        if ($this->filesystem->exists($dynamicDir)) {
92 1
            $this->filesystem->remove($dynamicDir);
93 1
        }
94 1
    }
95
}
96