Пример #1
0
 public function listGlobalModels()
 {
     if ($this->modelListCache !== null) {
         return $this->modelListCache;
     }
     $key = 'builder-global-model-list';
     $cached = Cache::get($key, false);
     if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
         return $this->modelListCache = $cached;
     }
     $plugins = PluginBaseModel::listAllPluginCodes();
     $result = [];
     foreach ($plugins as $pluginCode) {
         try {
             $pluginCodeObj = new PluginCode($pluginCode);
             $models = ModelModel::listPluginModels($pluginCodeObj);
             $pluginCodeStr = $pluginCodeObj->toCode();
             $pluginModelsNamespace = $pluginCodeObj->toPluginNamespace() . '\\Models\\';
             foreach ($models as $model) {
                 $fullClassName = $pluginModelsNamespace . $model->className;
                 $result[$fullClassName] = $pluginCodeStr . ' - ' . $model->className;
             }
         } catch (Exception $ex) {
             // Ignore invalid plugins and models
         }
     }
     Cache::put($key, serialize($result), 1);
     return $this->modelListCache = $result;
 }
Пример #2
0
 public function getBaseModelClassNameOptions()
 {
     $models = ModelModel::listPluginModels($this->getPluginCodeObj());
     $result = [];
     foreach ($models as $model) {
         $result[$model->className] = $model->className;
     }
     return $result;
 }
Пример #3
0
 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;
 }
Пример #4
0
 public static function getPluginRegistryDataAllRecords($pluginCode)
 {
     $pluginCodeObj = new PluginCode($pluginCode);
     $pluginDirectoryPath = $pluginCodeObj->toPluginDirectoryPath();
     $models = ModelModel::listPluginModels($pluginCodeObj);
     $result = [];
     foreach ($models as $model) {
         $modelRecords = self::listModelFiles($pluginCodeObj, $model->className);
         $modelDirectoryPath = $pluginDirectoryPath . '/models/' . strtolower($model->className) . '/';
         foreach ($modelRecords as $fileName) {
             $label = $model->className . '/' . $fileName;
             $key = $modelDirectoryPath . $fileName;
             $result[$key] = $label;
         }
     }
     return $result;
 }