| 包 | system.base |
|---|---|
| 继承 | abstract class CApplicationComponent » CComponent |
| 实现 | IApplicationComponent |
| 子类 | CAssetManager, CAuthManager, CCache, CClientScript, CDbConnection, CDbFixtureManager, CDummyCache, CErrorHandler, CFormatter, CHttpRequest, CHttpsession, CLogRouter, CMessageSource, CSecurityManager, CStatePersister, CThemeManager, curlManager, CViewRenderer, CWebUser, CWidgetFactory |
| 源自 | 1.0 |
| 版本 | $Id: CApplicationComponent.php 3515 2011-12-28 12:29:24Z mDOMba $ |
| 源码 |
CApplicationComponent是所有应用组件类的基类。
CApplicationComponent 必须实现IApplicationComponent的基本方法.
当开发一个应用组件, 尽量把应用组件的初始化代码放到init()方法中而不是构造方法。 这是应用组件可以通过配置进行定制的。
CApplicationComponent 必须实现IApplicationComponent的基本方法.
当开发一个应用组件, 尽量把应用组件的初始化代码放到init()方法中而不是构造方法。 这是应用组件可以通过配置进行定制的。
公共属性
| 属性 | 类型 | 描述 | 定义在 |
|---|---|---|---|
| behaviors | array | 这个应用组件附加的行为。 这此行为将在应用组件调用init时附加在应用组件上。 请参照CModel::behaviors如何指定此属性值。 | CApplicationComponent |
| isInitialized | boolean | 检查应用组件是否已经初始化。 | CApplicationComponent |
公共方法
| 方法 | 描述 | 定义在 |
|---|---|---|
| __call() | 如果类中没有调的方法名,则调用这个方法。 | CComponent |
| __get() | 返回一个属性值、一个事件处理程序列表或一个行为名称。 | CComponent |
| __isset() | 检查一个属性是否为null。 | CComponent |
| __set() | 设置一个组件的属性值。 | CComponent |
| __unset() | 设置一个组件的属性为null。 | CComponent |
| asa() | 返回这个名字的行为对象。 | CComponent |
| attachBehavior() | 附加一个行为到组件。 | CComponent |
| attachBehaviors() | 附加一个行为列表到组件。 | CComponent |
| attachEventHandler() | 为事件附加一个事件处理程序。 | CComponent |
| canGetProperty() | 确定属性是否可读。 | CComponent |
| canSetProperty() | 确定属性是否可写。 | CComponent |
| detachBehavior() | 从组件中分离一个行为。 | CComponent |
| detachBehaviors() | 从组件中分离所有行为。 | CComponent |
| detachEventHandler() | 分离一个存在的事件处理程序。 | CComponent |
| disableBehavior() | 禁用一个附加行为。 | CComponent |
| disableBehaviors() | 禁用组件附加的所有行为。 | CComponent |
| enableBehavior() | 启用一个附加行为。 | CComponent |
| enableBehaviors() | 启用组件附加的所有行为。 | CComponent |
| evaLuateExpression() | 计算一个PHP表达式,或根据组件上下文执行回调。 | CComponent |
| getEventHandlers() | 返回一个事件的附加处理程序列表。 | CComponent |
| getIsInitialized() | 检查应用组件是否已经初始化。 | CApplicationComponent |
| hasEvent() | 确定一个事件是否定义。 | CComponent |
| hasEventHandler() | 检查事件是否有附加的处理程序。 | CComponent |
| hasProperty() | 确定属性是否被定义。 | CComponent |
| init() | 初始化应用组件。 | CApplicationComponent |
| raiseEvent() | 发起一个事件。 | CComponent |
属性详细
behaviors
属性
public array $behaviors;
这个应用组件附加的行为。 这此行为将在应用组件调用init时附加在应用组件上。 请参照CModel::behaviors如何指定此属性值。
isInitialized
属性
只读
public boolean getIsInitialized()
检查应用组件是否已经初始化。
方法详细
getIsInitialized()
方法
|
public boolean getIsInitialized()
| ||
| {return} | boolean | 是否应用组件被初始化(如init()被调用). |
public function getIsInitialized()
{
return $this->_initialized;
}
检查应用组件是否已经初始化。
init()
方法
|
public void init()
|
public function init()
{
$this->attachBehaviors($this->behaviors);
$this->_initialized=true;
}
初始化应用组件。 这个方法是IApplicationComponent所必须的并且应用程序会调用。 如果重载此方法,请确保调用父类的实现, 以便应用组件可以被标记为已初始化。