1 | <?php |
||
23 | class Application extends BaseApplication |
||
24 | { |
||
25 | /** |
||
26 | * name |
||
27 | * |
||
28 | * @const NAME |
||
29 | */ |
||
30 | const NAME = 'CLIFramework'; |
||
31 | |||
32 | /** |
||
33 | * version |
||
34 | * |
||
35 | * @const VERSION |
||
36 | */ |
||
37 | const VERSION = '0.0.1-dev'; |
||
38 | |||
39 | /** |
||
40 | * The kernel. |
||
41 | * |
||
42 | * @var \Symfony\Component\HttpKernel\KernelInterface $kernel |
||
43 | */ |
||
44 | private $kernel; |
||
45 | |||
46 | /** |
||
47 | * The container. |
||
48 | * |
||
49 | * @var \Symfony\Component\DependencyInjection\ContainerInterface $container |
||
50 | */ |
||
51 | private $container; |
||
52 | |||
53 | /** |
||
54 | * Construct the application. |
||
55 | * |
||
56 | * @param \Symfony\Component\HttpKernel\KernelInterface $kernel |
||
57 | */ |
||
58 | 4 | public function __construct(KernelInterface $kernel) |
|
59 | { |
||
60 | 4 | $this->kernel = $kernel; |
|
61 | 4 | $this->container = $kernel->getContainer(); |
|
62 | |||
63 | 4 | parent::__construct(self::NAME, self::VERSION); |
|
64 | |||
65 | 4 | if ($this->container->has('event_dispatcher')) { |
|
66 | 3 | $this->setDispatcher($this->container->get('event_dispatcher')); |
|
67 | 3 | } |
|
68 | |||
69 | 4 | $this->getDefinition()->addOption( |
|
70 | 4 | new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev') |
|
71 | 4 | ); |
|
72 | 4 | $this->getDefinition()->addOption( |
|
73 | 4 | new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.') |
|
74 | 4 | ); |
|
75 | 4 | } |
|
76 | |||
77 | /** |
||
78 | * Get kernel. |
||
79 | * |
||
80 | * @return \Symfony\Component\HttpKernel\KernelInterface |
||
81 | */ |
||
82 | 1 | public function getKernel() |
|
86 | |||
87 | /** |
||
88 | * Runs the current application. |
||
89 | * |
||
90 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
91 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
92 | * |
||
93 | * @return int |
||
94 | */ |
||
95 | 2 | public function doRun(InputInterface $input, OutputInterface $output) |
|
101 | |||
102 | /** |
||
103 | * Register commands into the application |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | 2 | protected function registerCommands() |
|
115 | } |
||
116 |