public function checkBehavior() { /** @var AttachBehavior $behavior */ $behavior = $this->getAttachBehavior(); $class = AttachBehavior::className(); $name = AttachBehavior::NAME; if (!$behavior) { throw new InvalidConfigException("Behavior '{$class}' with name '{$name}' does not exists in model"); } }
/** * @inheritdoc */ public function behaviors() { $behaviors = parent::behaviors(); $behaviors[] = ['class' => AttachBehavior::className(), 'models' => ['avatar' => ['class' => UserAvatarFile::className()]]]; return $behaviors; }