diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 5fea5f0..88d1c43 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -7,6 +7,7 @@ Yii Framework 2 Change Log - Bug #5260: `yii\i18n\Formatter::decimalSeparator` and `yii\i18n\Formatter::thousandSeparator` where not configurable when intl is not installed (execut, cebe) - Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe) - Enh #4275: Added `removeChildren()` to `yii\rbac\ManagerInterface` and implementations (samdark) +- Enh: Added `yii\base\Application::loadedModules` (qiangxue) 2.0.0-rc September 27, 2014 diff --git a/framework/base/Application.php b/framework/base/Application.php index ef90e34..cdcb577 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -180,6 +180,10 @@ abstract class Application extends Module * This property is managed by the application. Do not modify this property. */ public $state; + /** + * @var array list of loaded modules indexed by their class names. + */ + public $loadedModules = []; /** diff --git a/framework/base/Module.php b/framework/base/Module.php index f071198..d301421 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -123,10 +123,6 @@ class Module extends ServiceLocator * @var array child modules of this module */ private $_modules = []; - /** - * @var array list of currently requested modules indexed by their class names - */ - private static $_instances = []; /** @@ -151,7 +147,7 @@ class Module extends ServiceLocator public static function getInstance() { $class = get_called_class(); - return isset(self::$_instances[$class]) ? self::$_instances[$class] : null; + return isset(Yii::$app->loadedModules[$class]) ? Yii::$app->loadedModules[$class] : null; } /** @@ -162,9 +158,9 @@ class Module extends ServiceLocator public static function setInstance($instance) { if ($instance === null) { - unset(self::$_instances[get_called_class()]); + unset(Yii::$app->loadedModules[get_called_class()]); } else { - self::$_instances[get_class($instance)] = $instance; + Yii::$app->loadedModules[get_class($instance)] = $instance; } }