|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Eole\Silex; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; |
|
6
|
|
|
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; |
|
7
|
|
|
use Doctrine\ORM\Tools\Console\ConsoleRunner; |
|
8
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
10
|
|
|
use Symfony\Component\Console\Application as ConsoleApplication; |
|
11
|
|
|
use Eole\Silex\Application as SilexApplication; |
|
12
|
|
|
|
|
13
|
|
|
class Console extends ConsoleApplication |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var SilexApplication |
|
17
|
|
|
*/ |
|
18
|
|
|
private $silexApplication; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Console application constructor. |
|
22
|
|
|
* |
|
23
|
|
|
* @param SilexApplication $silexApplication |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct(SilexApplication $silexApplication) |
|
26
|
|
|
{ |
|
27
|
|
|
parent::__construct('Eole'); |
|
28
|
|
|
|
|
29
|
|
|
$this->silexApplication = $silexApplication; |
|
30
|
|
|
$this->silexApplication->boot(); |
|
31
|
|
|
$this->addDefaultOptions(); |
|
32
|
|
|
$this->registerCommands(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
private function addDefaultOptions() |
|
36
|
|
|
{ |
|
37
|
|
|
$this |
|
38
|
|
|
->getDefinition() |
|
39
|
|
|
->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev')) |
|
40
|
|
|
; |
|
41
|
|
|
|
|
42
|
|
|
$this |
|
43
|
|
|
->getDefinition() |
|
44
|
|
|
->addOption(new InputOption('--no-debug', null, InputOption::VALUE_REQUIRED, 'Is debug mode enabled.', true)) |
|
45
|
|
|
; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
private function registerCommands() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->registerDoctrineCommands(); |
|
51
|
|
|
$this->registerEoleCommands(); |
|
52
|
|
|
$this->registerSilexComands(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
private function registerDoctrineCommands() |
|
56
|
|
|
{ |
|
57
|
|
|
$em = $this->silexApplication['orm.em']; |
|
58
|
|
|
|
|
59
|
|
|
// Register Doctrine ORM commands |
|
60
|
|
|
$helperSet = new HelperSet(array( |
|
61
|
|
|
'db' => new ConnectionHelper($em->getConnection()), |
|
62
|
|
|
'em' => new EntityManagerHelper($em) |
|
63
|
|
|
)); |
|
64
|
|
|
|
|
65
|
|
|
$this->setHelperSet($helperSet); |
|
66
|
|
|
ConsoleRunner::addCommands($this); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
private function registerEoleCommands() |
|
70
|
|
|
{ |
|
71
|
|
|
$api = $this->silexApplication['eole.player_api']; |
|
72
|
|
|
$playerManager = $this->silexApplication['eole.player_manager']; |
|
73
|
|
|
|
|
74
|
|
|
$this->addCommands(array( |
|
75
|
|
|
new \Alcalyn\UserApi\Command\EncodePasswordCommand($playerManager), |
|
76
|
|
|
new \Eole\Core\Command\CreatePlayerCommand($api), |
|
77
|
|
|
new \Eole\Core\Command\CreateGuestCommand($api), |
|
78
|
|
|
new \Eole\Core\Command\RunRepositoryMethodCommand($this->silexApplication['orm.em']), |
|
79
|
|
|
)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
private function registerSilexComands() |
|
83
|
|
|
{ |
|
84
|
|
|
$this->addCommands(array( |
|
85
|
|
|
new Command\InstallGamesCommand($this->silexApplication), |
|
86
|
|
|
)); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|