mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-15 06:40:59 +08:00
simplified errorhandler registration.
This commit is contained in:
@ -184,9 +184,10 @@ abstract class Application extends Module
|
|||||||
|
|
||||||
$this->state = self::STATE_BEGIN;
|
$this->state = self::STATE_BEGIN;
|
||||||
|
|
||||||
$this->registerErrorHandler($config);
|
|
||||||
$this->preInit($config);
|
$this->preInit($config);
|
||||||
|
|
||||||
|
$this->registerErrorHandler($config);
|
||||||
|
|
||||||
Component::__construct($config);
|
Component::__construct($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,14 +310,6 @@ abstract class Application extends Module
|
|||||||
echo "Error: no errorHandler component is configured.\n";
|
echo "Error: no errorHandler component is configured.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
// allow using ErrorHandler from the app namespace
|
|
||||||
if (strncmp($config['components']['errorHandler']['class'], 'app\\', 4) === 0) {
|
|
||||||
if (isset($config['basePath'])) {
|
|
||||||
Yii::setAlias('@app', $config['basePath']);
|
|
||||||
} else {
|
|
||||||
throw new InvalidConfigException('The "basePath" configuration for the Application is required.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->set('errorHandler', $config['components']['errorHandler']);
|
$this->set('errorHandler', $config['components']['errorHandler']);
|
||||||
unset($config['components']['errorHandler']);
|
unset($config['components']['errorHandler']);
|
||||||
$this->getErrorHandler()->register();
|
$this->getErrorHandler()->register();
|
||||||
|
@ -187,17 +187,7 @@ class Application extends \yii\base\Application
|
|||||||
return array_merge(parent::coreComponents(), [
|
return array_merge(parent::coreComponents(), [
|
||||||
'request' => ['class' => 'yii\console\Request'],
|
'request' => ['class' => 'yii\console\Request'],
|
||||||
'response' => ['class' => 'yii\console\Response'],
|
'response' => ['class' => 'yii\console\Response'],
|
||||||
|
'errorHandler' => ['class' => 'yii\web\ErrorHandler'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the errorHandler component as a PHP error handler.
|
|
||||||
*/
|
|
||||||
protected function registerErrorHandler(&$config)
|
|
||||||
{
|
|
||||||
if (!isset($config['components']['errorHandler']['class'])) {
|
|
||||||
$config['components']['errorHandler']['class'] = 'yii\\console\\ErrorHandler';
|
|
||||||
}
|
|
||||||
parent::registerErrorHandler($config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -149,17 +149,7 @@ class Application extends \yii\base\Application
|
|||||||
'response' => ['class' => 'yii\web\Response'],
|
'response' => ['class' => 'yii\web\Response'],
|
||||||
'session' => ['class' => 'yii\web\Session'],
|
'session' => ['class' => 'yii\web\Session'],
|
||||||
'user' => ['class' => 'yii\web\User'],
|
'user' => ['class' => 'yii\web\User'],
|
||||||
|
'errorHandler' => ['class' => 'yii\web\ErrorHandler'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the errorHandler component as a PHP error handler.
|
|
||||||
*/
|
|
||||||
protected function registerErrorHandler(&$config)
|
|
||||||
{
|
|
||||||
if (!isset($config['components']['errorHandler']['class'])) {
|
|
||||||
$config['components']['errorHandler']['class'] = 'yii\\web\\ErrorHandler';
|
|
||||||
}
|
|
||||||
parent::registerErrorHandler($config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user