Browse Source

removed ApplicationComponent.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
edc48dc9c7
  1. 32
      framework/base/ApplicationComponent.php
  2. 11
      framework/base/Behavior.php
  3. 11
      framework/base/Component.php
  4. 2
      framework/base/ErrorHandler.php
  5. 10
      framework/base/Module.php
  6. 2
      framework/base/Request.php
  7. 2
      framework/base/Response.php
  8. 2
      framework/base/SecurityManager.php
  9. 2
      framework/base/Theme.php
  10. 4
      framework/base/UrlManager.php
  11. 5
      framework/db/Connection.php

32
framework/base/ApplicationComponent.php

@ -1,32 +0,0 @@
<?php
/**
* ApplicationComponent class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
/**
* ApplicationComponent is the base class for application component classes.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class ApplicationComponent extends Component
{
/**
* @var string unique ID of this application component
*/
public $id;
public function init()
{
parent::init();
if ($this->id === null) {
$this->id = get_class($this);
}
}
}

11
framework/base/Behavior.php

@ -80,13 +80,14 @@ class Behavior extends \yii\base\Object
* The default implementation will unset the [[owner]] property * The default implementation will unset the [[owner]] property
* and detach event handlers declared in [[events]]. * and detach event handlers declared in [[events]].
* Make sure you call the parent implementation if you override this method. * Make sure you call the parent implementation if you override this method.
* @param Component $owner the component that this behavior is to be detached from.
*/ */
public function detach($owner) public function detach()
{ {
foreach ($this->events() as $event => $handler) { if ($this->owner) {
$owner->off($event, is_string($handler) ? array($this, $handler) : $handler); foreach ($this->events() as $event => $handler) {
$this->owner->off($event, is_string($handler) ? array($this, $handler) : $handler);
}
$this->owner = null;
} }
$this->owner = null;
} }
} }

11
framework/base/Component.php

@ -76,7 +76,8 @@ class Component extends \yii\base\Object
* will be implicitly called when executing `$component->property = $value;`. * will be implicitly called when executing `$component->property = $value;`.
* @param string $name the property name or the event name * @param string $name the property name or the event name
* @param mixed $value the property value * @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined or read-only. * @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only.
* @see __get * @see __get
*/ */
public function __set($name, $value) public function __set($name, $value)
@ -151,7 +152,7 @@ class Component extends \yii\base\Object
* Do not call this method directly as it is a PHP magic method that * Do not call this method directly as it is a PHP magic method that
* will be implicitly called when executing `unset($component->property)`. * will be implicitly called when executing `unset($component->property)`.
* @param string $name the property name * @param string $name the property name
* @throws UnknownPropertyException if the property is read only. * @throws InvalidCallException if the property is read only.
*/ */
public function __unset($name) public function __unset($name)
{ {
@ -421,7 +422,7 @@ class Component extends \yii\base\Object
public function trigger($name, $event = null) public function trigger($name, $event = null)
{ {
$this->ensureBehaviors(); $this->ensureBehaviors();
if (isset($this->_e[$name])) { if (isset($this->_e[$name]) && $this->_e[$name]->getCount()) {
if ($event === null) { if ($event === null) {
$event = new Event($this); $event = new Event($this);
} }
@ -505,7 +506,7 @@ class Component extends \yii\base\Object
if (isset($this->_b[$name])) { if (isset($this->_b[$name])) {
$behavior = $this->_b[$name]; $behavior = $this->_b[$name];
unset($this->_b[$name]); unset($this->_b[$name]);
$behavior->detach($this); $behavior->detach();
return $behavior; return $behavior;
} else { } else {
return null; return null;
@ -550,7 +551,7 @@ class Component extends \yii\base\Object
$behavior = \Yii::createObject($behavior); $behavior = \Yii::createObject($behavior);
} }
if (isset($this->_b[$name])) { if (isset($this->_b[$name])) {
$this->_b[$name]->detach($this); $this->_b[$name]->detach();
} }
$behavior->attach($this); $behavior->attach($this);
return $this->_b[$name] = $behavior; return $this->_b[$name] = $behavior;

2
framework/base/ErrorHandler.php

@ -20,7 +20,7 @@ namespace yii\base;
*/ */
use yii\util\VarDumper; use yii\util\VarDumper;
class ErrorHandler extends ApplicationComponent class ErrorHandler extends Component
{ {
/** /**
* @var integer maximum number of source code lines to be displayed. Defaults to 25. * @var integer maximum number of source code lines to be displayed. Defaults to 25.

10
framework/base/Module.php

@ -427,14 +427,14 @@ abstract class Module extends Component
* Retrieves the named application component. * Retrieves the named application component.
* @param string $id application component ID (case-sensitive) * @param string $id application component ID (case-sensitive)
* @param boolean $load whether to load the component if it is not yet loaded. * @param boolean $load whether to load the component if it is not yet loaded.
* @return ApplicationComponent|null the application component instance, null if the application component * @return Component|null the application component instance, null if the application component
* does not exist. * does not exist.
* @see hasComponent() * @see hasComponent()
*/ */
public function getComponent($id, $load = true) public function getComponent($id, $load = true)
{ {
if (isset($this->_components[$id])) { if (isset($this->_components[$id])) {
if ($this->_components[$id] instanceof ApplicationComponent) { if ($this->_components[$id] instanceof Component) {
return $this->_components[$id]; return $this->_components[$id];
} elseif ($load) { } elseif ($load) {
\Yii::trace("Loading \"$id\" application component", __CLASS__); \Yii::trace("Loading \"$id\" application component", __CLASS__);
@ -447,10 +447,10 @@ abstract class Module extends Component
/** /**
* Registers an application component in this module. * Registers an application component in this module.
* @param string $id component ID * @param string $id component ID
* @param ApplicationComponent|array|null $component the component to be added to the module. This can * @param Component|array|null $component the component to be added to the module. This can
* be one of the followings: * be one of the followings:
* *
* - an [[ApplicationComponent]] object * - a [[Component]] object
* - a configuration array: when [[getComponent()]] is called initially for this component, the array * - a configuration array: when [[getComponent()]] is called initially for this component, the array
* will be used to instantiate the component * will be used to instantiate the component
* - null: the named component will be removed from the module * - null: the named component will be removed from the module
@ -476,7 +476,7 @@ abstract class Module extends Component
if ($loadedOnly) { if ($loadedOnly) {
$components = array(); $components = array();
foreach ($this->_components as $component) { foreach ($this->_components as $component) {
if ($component instanceof ApplicationComponent) { if ($component instanceof Component) {
$components[] = $component; $components[] = $component;
} }
} }

2
framework/base/Request.php

@ -13,7 +13,7 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Request extends ApplicationComponent class Request extends Component
{ {
private $_scriptFile; private $_scriptFile;
private $_isConsoleRequest; private $_isConsoleRequest;

2
framework/base/Response.php

@ -13,7 +13,7 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Response extends ApplicationComponent class Response extends Component
{ {
public function beginOutput() public function beginOutput()
{ {

2
framework/base/SecurityManager.php

@ -15,7 +15,7 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class SecurityManager extends ApplicationComponent class SecurityManager extends Component
{ {
const STATE_VALIDATION_KEY = 'Yii.SecurityManager.validationkey'; const STATE_VALIDATION_KEY = 'Yii.SecurityManager.validationkey';
const STATE_ENCRYPTION_KEY = 'Yii.SecurityManager.encryptionkey'; const STATE_ENCRYPTION_KEY = 'Yii.SecurityManager.encryptionkey';

2
framework/base/Theme.php

@ -17,7 +17,7 @@ use yii\base\InvalidConfigException;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Theme extends ApplicationComponent class Theme extends Component
{ {
public $basePath; public $basePath;
public $baseUrl; public $baseUrl;

4
framework/base/UrlManager.php

@ -9,7 +9,7 @@
namespace yii\base; namespace yii\base;
use \yii\base\ApplicationComponent; use \yii\base\Component;
/** /**
* UrlManager manages the URLs of Yii applications. * UrlManager manages the URLs of Yii applications.
@ -123,7 +123,7 @@ use \yii\base\ApplicationComponent;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class UrlManager extends ApplicationComponent class UrlManager extends Component
{ {
const CACHE_KEY='Yii.UrlManager.rules'; const CACHE_KEY='Yii.UrlManager.rules';
const GET_FORMAT='get'; const GET_FORMAT='get';

5
framework/db/Connection.php

@ -9,6 +9,7 @@
namespace yii\db; namespace yii\db;
use yii\base\Component;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\NotSupportedException; use yii\base\NotSupportedException;
@ -70,7 +71,7 @@ use yii\base\NotSupportedException;
* } * }
* ~~~ * ~~~
* *
* Connection is often used as an [[\yii\base\ApplicationComponent|application component]] and configured in the application * Connection is often used as an application component and configured in the application
* configuration like the following: * configuration like the following:
* *
* ~~~ * ~~~
@ -98,7 +99,7 @@ use yii\base\NotSupportedException;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Connection extends \yii\base\ApplicationComponent class Connection extends Component
{ {
/** /**
* @event Event an event that is triggered after a DB connection is established * @event Event an event that is triggered after a DB connection is established

Loading…
Cancel
Save