1 | <?php |
||
19 | class Application extends Console |
||
20 | { |
||
21 | /** |
||
22 | * Input definition for user specific arguments and options. |
||
23 | * |
||
24 | * @var InputDefinition |
||
25 | */ |
||
26 | private $userDefinition; |
||
27 | |||
28 | /** |
||
29 | * @var callable |
||
30 | */ |
||
31 | private $catchIO; |
||
32 | |||
33 | /** |
||
34 | * @var callable |
||
35 | */ |
||
36 | private $after; |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 22 | protected function getDefaultInputDefinition() |
|
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 22 | protected function getDefaultCommands() |
|
56 | { |
||
57 | 22 | $commands = parent::getDefaultCommands(); |
|
58 | |||
59 | 22 | if ($this->isPharArchive()) { |
|
60 | $commands[] = $this->selfUpdateCommand(); |
||
61 | } |
||
62 | |||
63 | 22 | return $commands; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | private function selfUpdateCommand() |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 22 | protected function getDefaultHelperSet() |
|
81 | { |
||
82 | 22 | $helperSet = parent::getDefaultHelperSet(); |
|
83 | |||
84 | 22 | if ($this->isPharArchive()) { |
|
85 | $helperSet->set(new PharUpdateHelper()); |
||
86 | } |
||
87 | 22 | return $helperSet; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return InputDefinition |
||
92 | */ |
||
93 | 7 | public function getUserDefinition() |
|
101 | |||
102 | /** |
||
103 | * Add user definition arguments and options to definition. |
||
104 | */ |
||
105 | 7 | public function addUserArgumentsAndOptions() |
|
110 | |||
111 | /** |
||
112 | * @return bool |
||
113 | */ |
||
114 | 22 | public function isPharArchive() |
|
115 | { |
||
116 | 22 | return 'phar:' === substr(__FILE__, 0, 5); |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | 7 | protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) |
|
149 | |||
150 | /** |
||
151 | * @param $callable |
||
152 | */ |
||
153 | 7 | public function catchIO($callable) |
|
157 | |||
158 | /** |
||
159 | * @param $callable |
||
160 | */ |
||
161 | 7 | public function afterRun($callable) |
|
165 | } |
||
166 |