Modify CliController for opportunity to extend this class.
This commit is contained in:
@ -46,7 +46,7 @@ class CliController
|
|||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if (!isset(self::$instance)) {
|
if (!isset(self::$instance)) {
|
||||||
self::$instance = new self();
|
self::$instance = new static();
|
||||||
}
|
}
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
@ -58,6 +58,15 @@ class CliController
|
|||||||
public function execute($cli)
|
public function execute($cli)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->run($cli);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$this->exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function run($cli)
|
||||||
|
{
|
||||||
if (is_string($cli)) {
|
if (is_string($cli)) {
|
||||||
if (!class_exists($cli)) {
|
if (!class_exists($cli)) {
|
||||||
throw new GeneralException('Action class "' . $cli . '" not found.');
|
throw new GeneralException('Action class "' . $cli . '" not found.');
|
||||||
@ -77,7 +86,9 @@ class CliController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
|
||||||
|
protected function exception($e)
|
||||||
|
{
|
||||||
$code = $e->getCode();
|
$code = $e->getCode();
|
||||||
if ($e instanceof ErrorException) {
|
if ($e instanceof ErrorException) {
|
||||||
$code = $e->getSeverity();
|
$code = $e->getSeverity();
|
||||||
@ -85,5 +96,4 @@ class CliController
|
|||||||
file_put_contents($this->error_stream, PHP_EOL . 'Error ' . '#' . $code . ': ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
file_put_contents($this->error_stream, PHP_EOL . 'Error ' . '#' . $code . ': ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||||
file_put_contents($this->error_stream, PHP_EOL . 'Stack trace: ' . PHP_EOL . $e->getTraceAsString() . PHP_EOL, FILE_APPEND);
|
file_put_contents($this->error_stream, PHP_EOL . 'Stack trace: ' . PHP_EOL . $e->getTraceAsString() . PHP_EOL, FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user