mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-13 04:38:03 +08:00
removed ApplicationComponent.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ApplicationComponent class file.
|
||||
*
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright © 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,13 +80,14 @@ class Behavior extends \yii\base\Object
|
||||
* The default implementation will unset the [[owner]] property
|
||||
* and detach event handlers declared in [[events]].
|
||||
* 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) {
|
||||
$owner->off($event, is_string($handler) ? array($this, $handler) : $handler);
|
||||
if ($this->owner) {
|
||||
foreach ($this->events() as $event => $handler) {
|
||||
$this->owner->off($event, is_string($handler) ? array($this, $handler) : $handler);
|
||||
}
|
||||
$this->owner = null;
|
||||
}
|
||||
$this->owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ class Component extends \yii\base\Object
|
||||
* will be implicitly called when executing `$component->property = $value;`.
|
||||
* @param string $name the property name or the event name
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
* will be implicitly called when executing `unset($component->property)`.
|
||||
* @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)
|
||||
{
|
||||
@@ -421,7 +422,7 @@ class Component extends \yii\base\Object
|
||||
public function trigger($name, $event = null)
|
||||
{
|
||||
$this->ensureBehaviors();
|
||||
if (isset($this->_e[$name])) {
|
||||
if (isset($this->_e[$name]) && $this->_e[$name]->getCount()) {
|
||||
if ($event === null) {
|
||||
$event = new Event($this);
|
||||
}
|
||||
@@ -505,7 +506,7 @@ class Component extends \yii\base\Object
|
||||
if (isset($this->_b[$name])) {
|
||||
$behavior = $this->_b[$name];
|
||||
unset($this->_b[$name]);
|
||||
$behavior->detach($this);
|
||||
$behavior->detach();
|
||||
return $behavior;
|
||||
} else {
|
||||
return null;
|
||||
@@ -550,7 +551,7 @@ class Component extends \yii\base\Object
|
||||
$behavior = \Yii::createObject($behavior);
|
||||
}
|
||||
if (isset($this->_b[$name])) {
|
||||
$this->_b[$name]->detach($this);
|
||||
$this->_b[$name]->detach();
|
||||
}
|
||||
$behavior->attach($this);
|
||||
return $this->_b[$name] = $behavior;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace yii\base;
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -427,14 +427,14 @@ abstract class Module extends Component
|
||||
* Retrieves the named application component.
|
||||
* @param string $id application component ID (case-sensitive)
|
||||
* @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.
|
||||
* @see hasComponent()
|
||||
*/
|
||||
public function getComponent($id, $load = true)
|
||||
{
|
||||
if (isset($this->_components[$id])) {
|
||||
if ($this->_components[$id] instanceof ApplicationComponent) {
|
||||
if ($this->_components[$id] instanceof Component) {
|
||||
return $this->_components[$id];
|
||||
} elseif ($load) {
|
||||
\Yii::trace("Loading \"$id\" application component", __CLASS__);
|
||||
@@ -447,10 +447,10 @@ abstract class Module extends Component
|
||||
/**
|
||||
* Registers an application component in this module.
|
||||
* @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:
|
||||
*
|
||||
* - an [[ApplicationComponent]] object
|
||||
* - a [[Component]] object
|
||||
* - a configuration array: when [[getComponent()]] is called initially for this component, the array
|
||||
* will be used to instantiate the component
|
||||
* - null: the named component will be removed from the module
|
||||
@@ -476,7 +476,7 @@ abstract class Module extends Component
|
||||
if ($loadedOnly) {
|
||||
$components = array();
|
||||
foreach ($this->_components as $component) {
|
||||
if ($component instanceof ApplicationComponent) {
|
||||
if ($component instanceof Component) {
|
||||
$components[] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace yii\base;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Request extends ApplicationComponent
|
||||
class Request extends Component
|
||||
{
|
||||
private $_scriptFile;
|
||||
private $_isConsoleRequest;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace yii\base;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Response extends ApplicationComponent
|
||||
class Response extends Component
|
||||
{
|
||||
public function beginOutput()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace yii\base;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class SecurityManager extends ApplicationComponent
|
||||
class SecurityManager extends Component
|
||||
{
|
||||
const STATE_VALIDATION_KEY = 'Yii.SecurityManager.validationkey';
|
||||
const STATE_ENCRYPTION_KEY = 'Yii.SecurityManager.encryptionkey';
|
||||
|
||||
@@ -17,7 +17,7 @@ use yii\base\InvalidConfigException;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Theme extends ApplicationComponent
|
||||
class Theme extends Component
|
||||
{
|
||||
public $basePath;
|
||||
public $baseUrl;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace yii\base;
|
||||
|
||||
use \yii\base\ApplicationComponent;
|
||||
use \yii\base\Component;
|
||||
|
||||
/**
|
||||
* UrlManager manages the URLs of Yii applications.
|
||||
@@ -123,7 +123,7 @@ use \yii\base\ApplicationComponent;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class UrlManager extends ApplicationComponent
|
||||
class UrlManager extends Component
|
||||
{
|
||||
const CACHE_KEY='Yii.UrlManager.rules';
|
||||
const GET_FORMAT='get';
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace yii\db;
|
||||
|
||||
use yii\base\Component;
|
||||
use yii\base\InvalidConfigException;
|
||||
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:
|
||||
*
|
||||
* ~~~
|
||||
@@ -98,7 +99,7 @@ use yii\base\NotSupportedException;
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @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
|
||||
|
||||
Reference in New Issue
Block a user