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; }
public function getBaseModelClassNameOptions() { $models = ModelModel::listPluginModels($this->getPluginCodeObj()); $result = []; foreach ($models as $model) { $result[$model->className] = $model->className; } 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; }
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; }