protected function loadOrCreateBaseModel($pluginCode, $options = []) { $model = new PluginBaseModel(); if (!$pluginCode) { $model->initDefaults(); return $model; } $model->loadPlugin($pluginCode); return $model; }
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; }