| @@ 142-167 (lines=26) @@ | ||
| 139 | * @param Injectables|null $injectables |
|
| 140 | * @return integer |
|
| 141 | */ |
|
| 142 | public function processCommand(CliEngine $engine, $params = array(), $injectables = null) |
|
| 143 | { |
|
| 144 | // we need to wrap our code to catch old-style PHP errors |
|
| 145 | $legacyHandler = new Legacy_ErrorHandler(); |
|
| 146 | ||
| 147 | // run our code |
|
| 148 | try { |
|
| 149 | $returnCode = $legacyHandler->run([$this, 'processInsideLegacyHandler'], [$engine, $params, $injectables]); |
|
| 150 | return $returnCode; |
|
| 151 | } |
|
| 152 | catch (Exception $e) { |
|
| 153 | $injectables->output->logCliError($e->getMessage()); |
|
| 154 | $engine->options->dev = true; |
|
| 155 | if (isset($engine->options->dev) && $engine->options->dev) { |
|
| 156 | $injectables->output->logCliError("Stack trace is:\n\n" . $e->getTraceAsString()); |
|
| 157 | } |
|
| 158 | ||
| 159 | // stop the browser if available |
|
| 160 | if (isset($this->st)) { |
|
| 161 | $this->st->stopDevice(); |
|
| 162 | } |
|
| 163 | ||
| 164 | // tell the calling process that things did not end well |
|
| 165 | exit(1); |
|
| 166 | } |
|
| 167 | } |
|
| 168 | ||
| 169 | public function processInsideLegacyHandler(CliEngine $engine, $params = array(), $injectables = null) |
|
| 170 | { |
|
| @@ 158-183 (lines=26) @@ | ||
| 155 | * @param Injectables|null $injectables |
|
| 156 | * @return integer |
|
| 157 | */ |
|
| 158 | public function processCommand(CliEngine $engine, $params = array(), $injectables = null) |
|
| 159 | { |
|
| 160 | // we need to wrap our code to catch old-style PHP errors |
|
| 161 | $legacyHandler = new Legacy_ErrorHandler(); |
|
| 162 | ||
| 163 | // run our code |
|
| 164 | try { |
|
| 165 | $returnCode = $legacyHandler->run([$this, 'processInsideLegacyHandler'], [$engine, $params, $injectables]); |
|
| 166 | return $returnCode; |
|
| 167 | } |
|
| 168 | catch (Exception $e) { |
|
| 169 | $injectables->output->logCliError($e->getMessage()); |
|
| 170 | $engine->options->dev = true; |
|
| 171 | if (isset($engine->options->dev) && $engine->options->dev) { |
|
| 172 | $injectables->output->logCliError("Stack trace is:\n\n" . $e->getTraceAsString()); |
|
| 173 | } |
|
| 174 | ||
| 175 | // stop the browser if available |
|
| 176 | if (isset($this->st)) { |
|
| 177 | $this->st->stopDevice(); |
|
| 178 | } |
|
| 179 | ||
| 180 | // tell the calling process that things did not end well |
|
| 181 | exit(1); |
|
| 182 | } |
|
| 183 | } |
|
| 184 | ||
| 185 | public function processInsideLegacyHandler(CliEngine $engine, $params = array(), $injectables = null) |
|
| 186 | { |
|