/** * @param MonsterProvidersTrait|yii\base\Model $model * @param string $postKey */ protected function providersSupplied(&$model, $postKey) { if ($this->action() === self::ACTION_DEFAULT) { // skip on default action return; } $providers = ArrayHelper::getValue($this->visualBuilderProvided(), "{$postKey}.providers", null); if (is_array($providers) === false) { // no providers supplied return; } //! @todo add check for proper class names and properties here $model->setEntityDataProviders($providers); if ($this->action() === self::ACTION_SAVE) { $result = $model->hasMethod('saveMonsterContent') ? $model->saveMonsterContent() : $model->saveProviders(); if ($result === false) { throw new \Exception(var_export($model->errors, true)); } } }