Commit 858ceb50 by Qiang Xue

Added `yii\base\Application::loadedModules`

parent 76ade0f6
......@@ -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
......
......@@ -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 = [];
/**
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment