|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Saxulum\Console\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Pimple\Container; |
|
6
|
|
|
use Saxulum\Console\Command\AbstractPimpleCommand; |
|
7
|
|
|
use Symfony\Component\Console\Application as BaseConsoleApplication; |
|
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\OutputInterface; |
|
12
|
|
|
|
|
13
|
|
|
class ConsoleApplication extends BaseConsoleApplication |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \Pimple |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $container; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(Container $container) |
|
21
|
|
|
{ |
|
22
|
|
|
parent::__construct(); |
|
23
|
|
|
|
|
24
|
|
|
$this->container = $container; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
$this->getDefinition()->addOption( |
|
27
|
|
|
new InputOption( |
|
28
|
|
|
'--env', '-e', |
|
29
|
|
|
InputOption::VALUE_REQUIRED, |
|
30
|
|
|
'The Environment name.', |
|
31
|
|
|
isset($this->container['env']) ? $this->container['env'] : 'dev' |
|
32
|
|
|
) |
|
33
|
|
|
); |
|
34
|
|
|
$this->getDefinition()->addOption( |
|
35
|
|
|
new InputOption( |
|
36
|
|
|
'--no-debug', null, |
|
37
|
|
|
InputOption::VALUE_NONE, |
|
38
|
|
|
'Switches off debug mode.' |
|
39
|
|
|
) |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param Command $command |
|
45
|
|
|
* @return Command |
|
46
|
|
|
*/ |
|
47
|
|
|
public function add(Command $command) |
|
48
|
|
|
{ |
|
49
|
|
|
if ($command instanceof AbstractPimpleCommand) { |
|
50
|
|
|
$command->setContainer($this->container); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return parent::add($command); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param InputInterface $input |
|
58
|
|
|
* @param OutputInterface $output |
|
59
|
|
|
*/ |
|
60
|
|
|
public function configureIO(InputInterface $input, OutputInterface $output) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->container['env'] = $input->getParameterOption(array('--env', '-e'), getenv('APP_ENV') ?: 'dev'); |
|
63
|
|
|
$this->container['debug'] = getenv('APP_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $this->container['env'] !== 'prod'; |
|
64
|
|
|
|
|
65
|
|
|
parent::configureIO($input, $output); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..