protected function getFormControllerDefaultConfiguration($controllerModel, $controllerGenerator) { if (!$controllerModel->baseModelClassName) { throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_behavior_requires_base_model', ['behavior' => 'Form Controller'])); } $pluginCodeObj = $controllerModel->getPluginCodeObj(); $forms = ModelFormModel::listModelFiles($pluginCodeObj, $controllerModel->baseModelClassName); if (!$forms) { throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_model_doesnt_have_forms')); } $controllerUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller); $result = ['name' => $controllerModel->controller, 'form' => $this->getModelFilePath($pluginCodeObj, $controllerModel->baseModelClassName, $forms[0]), 'modelClass' => $this->getFullModelClass($pluginCodeObj, $controllerModel->baseModelClassName), 'defaultRedirect' => $controllerUrl, 'create' => ['redirect' => $controllerUrl . '/update/:id', 'redirectClose' => $controllerUrl], 'update' => ['redirect' => $controllerUrl, 'redirectClose' => $controllerUrl]]; return $result; }
protected function getModelList($pluginCode) { $models = ModelModel::listPluginModels($pluginCode); $result = []; foreach ($models as $model) { $result[] = ['model' => $model, 'forms' => ModelFormModel::listModelFiles($pluginCode, $model->className), 'lists' => ModelListModel::listModelFiles($pluginCode, $model->className)]; } return $result; }