yii\base\Component::getBehaviors PHP Méthode

getBehaviors() public méthode

Returns all behaviors attached to this component.
public getBehaviors ( ) : Behavior[]
Résultat Behavior[] list of behaviors attached to this component
    public function getBehaviors()
    {
        $this->ensureBehaviors();
        return $this->_behaviors;
    }

Usage Example

 /**
  * Getting behavior object from given model
  *
  * @param Component $model
  * @return SeoBehavior
  * @throws InvalidConfigException if model don't have our SeoBehavior
  */
 protected static function behavior(Component $model)
 {
     foreach ($model->getBehaviors() as $b) {
         if ($b instanceof SeoBehavior) {
             return $b;
         }
     }
     throw new InvalidConfigException('Model ' . $model->className() . ' must have SeoBehavior');
 }
All Usage Examples Of yii\base\Component::getBehaviors