1: <?php
2: /**
3: * This file contains the base application component class.
4: *
5: * @author Qiang Xue <qiang.xue@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11: /**
12: * CApplicationComponent is the base class for application component classes.
13: *
14: * CApplicationComponent implements the basic methods required by {@link IApplicationComponent}.
15: *
16: * When developing an application component, try to put application component initialization code in
17: * the {@link init()} method instead of the constructor. This has the advantage that
18: * the application component can be customized through application configuration.
19: *
20: * @property boolean $isInitialized Whether this application component has been initialized (ie, {@link init()} is invoked).
21: *
22: * @author Qiang Xue <qiang.xue@gmail.com>
23: * @package system.base
24: * @since 1.0
25: */
26: abstract class CApplicationComponent extends CComponent implements IApplicationComponent
27: {
28: /**
29: * @var array the behaviors that should be attached to this component.
30: * The behaviors will be attached to the component when {@link init} is called.
31: * Please refer to {@link CModel::behaviors} on how to specify the value of this property.
32: */
33: public $behaviors=array();
34:
35: private $_initialized=false;
36:
37: /**
38: * Initializes the application component.
39: * This method is required by {@link IApplicationComponent} and is invoked by application.
40: * If you override this method, make sure to call the parent implementation
41: * so that the application component can be marked as initialized.
42: */
43: public function init()
44: {
45: $this->attachBehaviors($this->behaviors);
46: $this->_initialized=true;
47: }
48:
49: /**
50: * Checks if this application component has been initialized.
51: * @return boolean whether this application component has been initialized (ie, {@link init()} is invoked).
52: */
53: public function getIsInitialized()
54: {
55: return $this->_initialized;
56: }
57: }
58: