1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
15
|
|
|
use Symfony\Component\Console\Command\Command; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
use Symfony\Component\Console\Style\StyleInterface; |
19
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
20
|
|
|
use WBW\Bundle\CoreBundle\Helper\CommandHelper; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Abstract command. |
24
|
|
|
* |
25
|
|
|
* @author webeweb <https://github.com/webeweb/> |
26
|
|
|
* @package WBW\Bundle\CoreBundle\Command |
27
|
|
|
* @abstract |
28
|
|
|
*/ |
29
|
|
|
abstract class AbstractCommand extends Command { |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Displays the header. |
33
|
|
|
* |
34
|
|
|
* @param StyleInterface $io The I/O. |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
protected function displayHeader(StyleInterface $io, $text) { |
38
|
|
|
$io->newLine(); |
39
|
|
|
$io->text($text); |
40
|
|
|
$io->newLine(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get a checkbox. |
45
|
|
|
* |
46
|
|
|
* @param bool $checked Checked ? |
47
|
|
|
* @return string Returns the checkbox. |
48
|
|
|
*/ |
49
|
|
|
protected function getCheckbox($checked) { |
50
|
|
|
return CommandHelper::getCheckbox($checked); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get the kernel. |
55
|
|
|
* |
56
|
|
|
* @return KernelInterface|null Returns the kernel in case of success, null othrewise. |
57
|
|
|
*/ |
58
|
|
|
public function getKernel() { |
59
|
|
|
if (false === ($this->getApplication() instanceof Application)) { |
60
|
|
|
return null; |
61
|
|
|
} |
62
|
|
|
return $this->getApplication()->getKernel(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Create a style. |
67
|
|
|
* |
68
|
|
|
* @param InputInterface $input The input. |
69
|
|
|
* @param OutputInterface $output The output. |
70
|
|
|
* @return StyleInterface Returns the style. |
71
|
|
|
*/ |
72
|
|
|
protected function newStyle(InputInterface $input, OutputInterface $output) { |
73
|
|
|
return CommandHelper::newSymfonyStyle($input, $output); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|