Fix #15202: Add optional param --silent-exit-on-exception in yii\console\Controller

This commit is contained in:
egorrishe
2020-06-23 13:34:09 +03:00
committed by GitHub
parent 2e21a8275c
commit 5c3ee63316
4 changed files with 31 additions and 2 deletions

View File

@ -65,6 +65,13 @@ class Controller extends \yii\base\Controller
* @since 2.0.10
*/
public $help;
/**
* @var bool if TRUE - script finish with `ExitCode::OK` in case of exception.
* FALSE - `ExitCode::UNSPECIFIED_ERROR`.
* Default: `YII_ENV_TEST`
* @since 2.0.36
*/
public $silentExitOnException;
/**
* @var array the options passed during execution.
@ -72,6 +79,14 @@ class Controller extends \yii\base\Controller
private $_passedOptions = [];
public function beforeAction($action)
{
$silentExit = $this->silentExitOnException !== null ? $this->silentExitOnException : YII_ENV_TEST;
Yii::$app->errorHandler->silentExitOnException = $silentExit;
return parent::beforeAction($action);
}
/**
* Returns a value indicating whether ANSI color is enabled.
*
@ -398,7 +413,7 @@ class Controller extends \yii\base\Controller
public function options($actionID)
{
// $actionId might be used in subclasses to provide options specific to action id
return ['color', 'interactive', 'help'];
return ['color', 'interactive', 'help', 'silentExitOnException'];
}
/**