mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Final touchup.
This commit is contained in:
@ -248,7 +248,11 @@ Yii Framework 2 Change Log
|
||||
- Chg: Added `View::viewFile` and removed `ViewEvent::viewFile` (qiangxue)
|
||||
- Chg: Changed `Controller::afterAction()`, `Module::afterAction()` and `ActionFilter::afterAction()` to pass `$result` by value instead of reference (qiangxue)
|
||||
- Chg: `yii\base\Extension::init()` is renamed to `bootstrap()` (qiangxue)
|
||||
- Chg: `getComponent()` and `setComponent()` in `Application` and `Module` are renamed to `get()` and `set()` respectively. (qiangxue)
|
||||
- Chg: The signature of `Yii::createObject()` is changed. Constructor parameters must be passed as the second parameter. (qiangxue)
|
||||
- Chg: `Yii::$objectConfig` is removed. You should use `Yii::$container->set()` to configure default settings of classes. (qiangxue)
|
||||
- New #66: [Auth client library](https://github.com/yiisoft/yii2-authclient) OpenId, OAuth1, OAuth2 clients (klimov-paul)
|
||||
- New #503: Added `yii\di\Container` and `yii\di\ServiceLocator` (qiangxue)
|
||||
- New #706: Added `yii\widgets\Pjax` and enhanced `GridView` to work with `Pjax` to support AJAX-update (qiangxue)
|
||||
- New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo)
|
||||
- New #1438: [MongoDB integration](https://github.com/yiisoft/yii2-mongodb) ActiveRecord and Query (klimov-paul)
|
||||
|
@ -126,36 +126,6 @@ class Module extends ServiceLocator
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter magic method.
|
||||
* This method is overridden to support accessing components like reading properties.
|
||||
* @param string $name component or property name
|
||||
* @return mixed the named property value
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
return $this->get($name);
|
||||
} else {
|
||||
return parent::__get($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a property value is null.
|
||||
* This method overrides the parent implementation by checking if the named component is loaded.
|
||||
* @param string $name the property name or the event name
|
||||
* @return boolean whether the property value is null
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
return $this->get($name, [], false) !== null;
|
||||
} else {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the module.
|
||||
* This method is called after the module is created and initialized with property values
|
||||
|
@ -35,8 +35,8 @@ use yii\base\InvalidConfigException;
|
||||
* ],
|
||||
* ]);
|
||||
*
|
||||
* $db = $locator->get('db');
|
||||
* $cache = $locator->get('cache');
|
||||
* $db = $locator->get('db'); // or $locator->db
|
||||
* $cache = $locator->get('cache'); // or $locator->cache
|
||||
* ```
|
||||
*
|
||||
* Because [[\yii\base\Module]] extends from ServiceLocator, modules and the application are all service locators.
|
||||
@ -56,6 +56,36 @@ class ServiceLocator extends Component
|
||||
private $_definitions = [];
|
||||
|
||||
|
||||
/**
|
||||
* Getter magic method.
|
||||
* This method is overridden to support accessing components like reading properties.
|
||||
* @param string $name component or property name
|
||||
* @return mixed the named property value
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
return $this->get($name);
|
||||
} else {
|
||||
return parent::__get($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a property value is null.
|
||||
* This method overrides the parent implementation by checking if the named component is loaded.
|
||||
* @param string $name the property name or the event name
|
||||
* @return boolean whether the property value is null
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
if ($this->has($name, true)) {
|
||||
return true;
|
||||
} else {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether the locator has the specified component definition or has instantiated the component.
|
||||
* This method may return different results depending on the value of `$checkInstance`.
|
||||
|
Reference in New Issue
Block a user