From b1c4416218f2372ea5bf121c12bfd1a527bf1b01 Mon Sep 17 00:00:00 2001
From: Qiang Xue <qiang.xue@gmail.com>
Date: Fri, 21 Mar 2014 00:02:15 -0400
Subject: [PATCH] Final touchup.

---
 framework/CHANGELOG.md          |  4 ++++
 framework/base/Module.php       | 30 ------------------------------
 framework/di/ServiceLocator.php | 34 ++++++++++++++++++++++++++++++++--
 3 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md
index 213eac1..3ea5288 100644
--- a/framework/CHANGELOG.md
+++ b/framework/CHANGELOG.md
@@ -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)
diff --git a/framework/base/Module.php b/framework/base/Module.php
index ee6cfba..365809d 100644
--- a/framework/base/Module.php
+++ b/framework/base/Module.php
@@ -127,36 +127,6 @@ class Module extends ServiceLocator
     }
 
     /**
-     * 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
      * given in configuration. The default implementation will call [[preloadComponents()]] to
diff --git a/framework/di/ServiceLocator.php b/framework/di/ServiceLocator.php
index 3e8530c..ea0b888 100644
--- a/framework/di/ServiceLocator.php
+++ b/framework/di/ServiceLocator.php
@@ -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.
@@ -57,6 +57,36 @@ class ServiceLocator extends Component
 
 
     /**
+     * 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`.
      *
--
libgit2 0.27.1