mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 20:19:42 +08:00
w
This commit is contained in:
@ -317,9 +317,6 @@ class YiiBase
|
||||
* pairs in the array will be used to initialize the corresponding object properties.
|
||||
* For example,
|
||||
*
|
||||
* Any additional parameters passed to this method will be
|
||||
* passed to the constructor of the object being created.
|
||||
*
|
||||
* ~~~
|
||||
* $component = Yii::createComponent('@app/components/GoogleMap');
|
||||
* $component = Yii::createComponent('\application\components\GoogleMap');
|
||||
@ -329,6 +326,13 @@ class YiiBase
|
||||
* ));
|
||||
* ~~~
|
||||
*
|
||||
* Any additional parameters passed to this method will be
|
||||
* passed to the constructor of the object being created.
|
||||
*
|
||||
* If a component class implements the [[\yii\base\Initable]] interface,
|
||||
* its [[\yii\base\Initable::init|init]] method will be invoked after
|
||||
* its properties have been initialized.
|
||||
*
|
||||
* @param mixed $config the configuration. It can be either a string or an array.
|
||||
* @return mixed the created object
|
||||
* @throws \yii\base\Exception if the configuration does not have a 'class' element.
|
||||
|
||||
@ -303,46 +303,6 @@ class Component
|
||||
throw new Exception('Unknown method: ' . get_class($this) . "::$name()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this component.
|
||||
* This method is invoked by [[\Yii::createComponent]] after its creates the new
|
||||
* component instance and initializes the component properties. In other words,
|
||||
* at this stage, the component has been fully configured.
|
||||
*
|
||||
* The default implementation calls [[behaviors]] and registers any available behaviors.
|
||||
* You may override this method with additional initialization logic (e.g. establish DB connection).
|
||||
* Make sure you call the parent implementation.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->attachBehaviors($this->behaviors());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of behaviors that this component should behave as.
|
||||
* The return value should be an array of behavior configurations indexed by
|
||||
* behavior names. Each behavior configuration can be either a string specifying
|
||||
* the behavior class or an array of the following structure:
|
||||
*
|
||||
* ~~~
|
||||
* 'behaviorName' => array(
|
||||
* 'class' => 'BehaviorClass',
|
||||
* 'property1' => 'value1',
|
||||
* 'property2' => 'value2',
|
||||
* )
|
||||
* ~~~
|
||||
*
|
||||
* Note that a behavior class must extend from [[Behavior]]. Behaviors declared
|
||||
* in this method will be attached to the model when [[init]] is invoked.
|
||||
*
|
||||
* @return array the behavior configurations.
|
||||
* @see init
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether a property is defined.
|
||||
* A property is defined if there is a getter or setter method
|
||||
|
||||
Reference in New Issue
Block a user