1 | <?php |
||
20 | class Application extends Console |
||
21 | { |
||
22 | /** |
||
23 | * Input definition for user specific arguments and options. |
||
24 | * |
||
25 | * @var InputDefinition |
||
26 | */ |
||
27 | private $userDefinition; |
||
28 | |||
29 | /** |
||
30 | * @var callable |
||
31 | */ |
||
32 | private $catchIO; |
||
33 | |||
34 | /** |
||
35 | * @var callable |
||
36 | */ |
||
37 | private $after; |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 4 | protected function getDefaultInputDefinition() |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 4 | protected function getDefaultCommands() |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | private function selfUpdateCommand() |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 4 | protected function getDefaultHelperSet() |
|
90 | |||
91 | /** |
||
92 | * @return InputDefinition |
||
93 | */ |
||
94 | 4 | public function getUserDefinition() |
|
102 | |||
103 | /** |
||
104 | * Add user definition arguments and options to definition. |
||
105 | */ |
||
106 | 4 | public function addUserArgumentsAndOptions() |
|
111 | |||
112 | /** |
||
113 | * @return bool |
||
114 | */ |
||
115 | 4 | public function isPharArchive() |
|
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | 3 | protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) |
|
124 | { |
||
125 | 3 | $exception = null; |
|
126 | 3 | $exitCode = 0; |
|
127 | |||
128 | 3 | if (!empty($this->catchIO)) { |
|
129 | 3 | list($input, $output) = call_user_func($this->catchIO, $input, $output); |
|
130 | } |
||
131 | |||
132 | try { |
||
133 | 3 | $exitCode = parent::doRunCommand($command, $input, $output); |
|
134 | } catch (\Exception $x) { |
||
135 | $exception = $x; |
||
136 | } catch (\Throwable $x) { |
||
137 | $exception = $x; |
||
138 | } |
||
139 | |||
140 | 3 | if (!empty($this->after)) { |
|
141 | call_user_func($this->after, new CommandEvent($command, $input, $output, $exception, $exitCode)); |
||
142 | } |
||
143 | |||
144 | 3 | if ($exception !== null) { |
|
145 | throw $exception; |
||
146 | } |
||
147 | |||
148 | 3 | return $exitCode; |
|
149 | } |
||
150 | |||
151 | /** |
||
152 | * @param $callable |
||
153 | */ |
||
154 | 4 | public function catchIO($callable) |
|
158 | |||
159 | /** |
||
160 | * @param $callable |
||
161 | */ |
||
162 | 4 | public function afterRun($callable) |
|
166 | } |
||
167 |