1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of CaptainHook |
5
|
|
|
* |
6
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
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 CaptainHook\App\Console; |
13
|
|
|
|
14
|
|
|
use CaptainHook\App\Console\Runtime\Resolver; |
15
|
|
|
use Symfony\Component\Console\Command\Command as SymfonyCommand; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Command |
21
|
|
|
* |
22
|
|
|
* @package CaptainHook |
23
|
|
|
* @author Sebastian Feldmann <[email protected]> |
24
|
|
|
* @link https://github.com/captainhookphp/captainhook |
25
|
|
|
* @since Class available since Release 5.0.0 |
26
|
|
|
*/ |
27
|
|
|
abstract class Command extends SymfonyCommand |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Input output handler |
31
|
|
|
* |
32
|
|
|
* @var \CaptainHook\App\Console\IO |
33
|
|
|
*/ |
34
|
|
|
private $io; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Runtime resolver |
38
|
|
|
* |
39
|
|
|
* @var \CaptainHook\App\Console\Runtime\Resolver |
40
|
|
|
*/ |
41
|
|
|
protected $resolver; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Command constructor |
45
|
|
|
* |
46
|
|
|
* @param \CaptainHook\App\Console\Runtime\Resolver $resolver |
47
|
|
|
*/ |
48
|
|
|
public function __construct(Resolver $resolver) |
49
|
|
|
{ |
50
|
|
|
$this->resolver = $resolver; |
51
|
|
|
parent::__construct(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* IO setter |
56
|
|
|
* |
57
|
|
|
* @param \CaptainHook\App\Console\IO $io |
58
|
|
|
*/ |
59
|
|
|
public function setIO(IO $io): void |
60
|
|
|
{ |
61
|
|
|
$this->io = $io; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* IO interface getter |
66
|
|
|
* |
67
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
68
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
69
|
|
|
* @return \CaptainHook\App\Console\IO |
70
|
|
|
*/ |
71
|
|
|
public function getIO(InputInterface $input, OutputInterface $output): IO |
72
|
|
|
{ |
73
|
|
|
if (null === $this->io) { |
74
|
|
|
$this->io = new IO\DefaultIO($input, $output, $this->getHelperSet()); |
75
|
|
|
} |
76
|
|
|
return $this->io; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|