コード例 #1
0
 protected function getListControllerDefaultConfiguration($controllerModel, $controllerGenerator)
 {
     if (!$controllerModel->baseModelClassName) {
         throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_behavior_requires_base_model', ['behavior' => 'List Controller']));
     }
     $pluginCodeObj = $controllerModel->getPluginCodeObj();
     $lists = ModelListModel::listModelFiles($pluginCodeObj, $controllerModel->baseModelClassName);
     if (!$lists) {
         throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_model_doesnt_have_lists'));
     }
     $result = ['list' => $this->getModelFilePath($pluginCodeObj, $controllerModel->baseModelClassName, $lists[0]), 'modelClass' => $this->getFullModelClass($pluginCodeObj, $controllerModel->baseModelClassName), 'title' => $controllerModel->controller, 'noRecordsMessage' => 'backend::lang.list.no_records', 'showSetup' => true, 'showCheckboxes' => true, 'toolbar' => ['buttons' => 'list_toolbar', 'search' => ['prompt' => 'backend::lang.list.search_prompt']]];
     if (in_array('Backend\\Behaviors\\FormController', $controllerModel->behaviors)) {
         $updateUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller) . '/update/:id';
         $createUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller) . '/create';
         $result['recordUrl'] = $updateUrl;
         $controllerGenerator->setTemplateVariable('hasFormBehavior', true);
         $controllerGenerator->setTemplateVariable('createUrl', $createUrl);
     }
     return $result;
 }
コード例 #2
0
ファイル: ModelList.php プロジェクト: andytan2624/andytan.net
 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;
 }