mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fix #15202: Add optional param --silent-exit-on-exception
in yii\console\Controller
This commit is contained in:
@ -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'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user