Browse Source

Fixes #3542: Removed requirement to specify `extensions` in application config

tags/2.0.0-rc
Alexander Makarov 10 years ago
parent
commit
07f30cb04c
  1. 1
      apps/advanced/common/config/main.php
  2. 1
      apps/basic/config/console.php
  3. 1
      apps/basic/config/web.php
  4. 1
      framework/CHANGELOG.md
  5. 13
      framework/base/Application.php

1
apps/advanced/common/config/main.php

@ -1,7 +1,6 @@
<?php <?php
return [ return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'cache' => [ 'cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',

1
apps/basic/config/console.php

@ -10,7 +10,6 @@ return [
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'controllerNamespace' => 'app\commands', 'controllerNamespace' => 'app\commands',
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'cache' => [ 'cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',

1
apps/basic/config/web.php

@ -6,7 +6,6 @@ $config = [
'id' => 'basic', 'id' => 'basic',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'cache' => [ 'cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',

1
framework/CHANGELOG.md

@ -54,6 +54,7 @@ Yii Framework 2 Change Log
- Enh #3472: Added configurable option to encode spaces in dropDownLists and listBoxes (kartik-v) - Enh #3472: Added configurable option to encode spaces in dropDownLists and listBoxes (kartik-v)
- Enh #3518: `yii\helpers\Html::encode()` now replaces invalid code sequences with "?" (DaSourcerer) - Enh #3518: `yii\helpers\Html::encode()` now replaces invalid code sequences with "?" (DaSourcerer)
- Enh #3521: Added `yii\filters\HttpCache::sessionCacheLimiter` (qiangxue) - Enh #3521: Added `yii\filters\HttpCache::sessionCacheLimiter` (qiangxue)
- Enh #3542: Removed requirement to specify `extensions` in application config (samdark)
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue) - Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)

13
framework/base/Application.php

@ -8,6 +8,7 @@
namespace yii\base; namespace yii\base;
use Yii; use Yii;
use yii\log\Logger;
/** /**
* Application is the base class for all application classes. * Application is the base class for all application classes.
@ -151,8 +152,11 @@ abstract class Application extends Module
* The "bootstrap" class listed above will be instantiated during the application * The "bootstrap" class listed above will be instantiated during the application
* [[bootstrap()|bootstrapping process]]. If the class implements [[BootstrapInterface]], * [[bootstrap()|bootstrapping process]]. If the class implements [[BootstrapInterface]],
* its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called. * its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called.
*
* If the property isn't specified in the application bootstrap file i.e. index.php, content is loaded automatically
* from @vendor/yiisoft/extensions.php.
*/ */
public $extensions = []; public $extensions;
/** /**
* @var array list of components that should be run during the application [[bootstrap()|bootstrapping process]]. * @var array list of components that should be run during the application [[bootstrap()|bootstrapping process]].
* *
@ -262,6 +266,13 @@ abstract class Application extends Module
*/ */
protected function bootstrap() protected function bootstrap()
{ {
if ($this->extensions === null) {
try {
$this->extensions = include Yii::getAlias('@vendor/yiisoft/extensions.php');
} catch (ErrorException $e) {
$this->extensions = [];
}
}
foreach ($this->extensions as $extension) { foreach ($this->extensions as $extension) {
if (!empty($extension['alias'])) { if (!empty($extension['alias'])) {
foreach ($extension['alias'] as $name => $path) { foreach ($extension['alias'] as $name => $path) {

Loading…
Cancel
Save