1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BrainExe\Core\Console; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Application; |
6
|
|
|
use Symfony\Component\Console\Command\Command; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
use Symfony\Component\DependencyInjection\Container; |
10
|
|
|
|
11
|
|
|
class ProxyCommand extends Command |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var Container |
16
|
|
|
*/ |
17
|
|
|
private $container; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $serviceId; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param Container $container |
26
|
|
|
* @param Application $application |
27
|
|
|
* @param string $serviceId |
28
|
|
|
* @param string $name |
29
|
|
|
* @param string $description |
30
|
|
|
* @param string|array $alias |
31
|
|
|
* @param array $definition |
32
|
|
|
*/ |
33
|
|
|
public function __construct( |
34
|
|
|
Container $container, |
35
|
|
|
Application $application, |
|
|
|
|
36
|
|
|
string $serviceId, |
37
|
|
|
string $name, |
38
|
|
|
$description, |
39
|
|
|
$alias, |
40
|
|
|
array $definition |
41
|
|
|
) { |
42
|
|
|
|
43
|
|
|
$this->setName($name); |
44
|
|
|
$this->setDescription($description); |
45
|
|
|
$this->setAliases($alias); |
|
|
|
|
46
|
|
|
|
47
|
|
|
$this->container = $container; |
48
|
|
|
$this->serviceId = $serviceId; |
49
|
|
|
|
50
|
|
|
parent::__construct(); |
51
|
|
|
|
52
|
|
|
$this->setDefinition($definition); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param InputInterface $input |
57
|
|
|
* @param OutputInterface $output |
58
|
|
|
* @return int|null |
59
|
|
|
*/ |
60
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
61
|
|
|
{ |
62
|
|
|
/** @var Command $child */ |
63
|
|
|
$child = $this->container->get($this->serviceId); |
64
|
|
|
$child->setApplication($this->getApplication()); |
65
|
|
|
$child->setDefinition($this->getDefinition()); |
66
|
|
|
|
67
|
|
|
return $child->execute($input, $output); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.