mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 23:43:19 +08:00
modified Application constructor signature.
This commit is contained in:
@@ -98,16 +98,24 @@ class Application extends Module
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param string $id the ID of this application. The ID should uniquely identify the application from others.
|
* @param array $config name-value pairs that will be used to initialize the object properties.
|
||||||
* @param string $basePath the base path of this application. This should point to
|
* Note that the configuration must contain both [[id]] and [[basePath]].
|
||||||
* the directory containing all application logic, template and data.
|
* @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
|
||||||
* @param array $config name-value pairs that will be used to initialize the object properties
|
|
||||||
*/
|
*/
|
||||||
public function __construct($id, $basePath, $config = array())
|
public function __construct($config = array())
|
||||||
{
|
{
|
||||||
Yii::$app = $this;
|
Yii::$app = $this;
|
||||||
$this->id = $id;
|
|
||||||
$this->setBasePath($basePath);
|
if (!isset($config['id'])) {
|
||||||
|
throw new InvalidConfigException('The "id" configuration is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($config['basePath'])) {
|
||||||
|
$this->setBasePath($config['basePath']);
|
||||||
|
unset($config['basePath']);
|
||||||
|
} else {
|
||||||
|
throw new InvalidConfigException('The "basePath" configuration is required.');
|
||||||
|
}
|
||||||
|
|
||||||
if (YII_ENABLE_ERROR_HANDLER) {
|
if (YII_ENABLE_ERROR_HANDLER) {
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ class HtmlTest extends \yii\test\TestCase
|
|||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
new Application('test', '@yiiunit/runtime', array(
|
new Application(array(
|
||||||
|
'id' => 'test',
|
||||||
|
'basePath' => '@yiiunit/runtime',
|
||||||
'components' => array(
|
'components' => array(
|
||||||
'request' => array(
|
'request' => array(
|
||||||
'class' => 'yii\web\Request',
|
'class' => 'yii\web\Request',
|
||||||
|
|||||||
Reference in New Issue
Block a user