base behavior
- Ejemplos
Si desea crear un comportamiento Active Record, usted tendrá que extender directamente de yii\base\Behavior. | If you want to create an Active Record Behavior, you will have to extend directly from yii\base\Behavior. |
Para definir un comportamiento, se debe crear una clase que exiende yii\base\Behavior, o se extiende una clase hija. | To define a behavior, create a class that extends yii\base\Behavior, or extends a child class. |
Consejo: Dentro de un comportamiento, puede acceder al componente que el comportamiento está unido a través de la propiedad yii\base\Behavior::$owner. | Tip: Within a behavior, you can access the component that the behavior is attached to through the yii\base\Behavior::$owner property. |
Este caso es porque yii\base\Behavior extiende yii\base\BaseObject y por lo tanto se apoya en la definición de propiedades vía getters y setters. | This is the case because yii\base\Behavior extends yii\base\BaseObject and therefore supports defining properties via getters and setters. |
Si un comportamiento necesita responder a los acontecimientos desencadenados por el componente al que está unido, se debe reemplazar el método yii\base\Behavior::events(). | If a behavior needs to respond to the events triggered by the component it is attached to, it should override the yii\base\Behavior::events() method. |
