protected function loadOrCreateListFromPost() { $pluginCodeObj = new PluginCode(Request::input('plugin_code')); $options = ['pluginCode' => $pluginCodeObj->toCode()]; $versionNumber = Input::get('original_version'); return $this->loadOrCreateBaseModel($versionNumber, $options); }
/** * Wrap migration's up() and down() functions into a complete migration class declaration * @param string $scriptFileName Specifies the migration script file name * @param string $code Specifies the migration code * @param PluginCode $pluginCodeObj The plugin code object */ public function wrapMigrationCode($scriptFilename, $code, $pluginCodeObj) { $templatePath = '$/rainlab/builder/classes/databasetablemodel/templates/full-migration-code.php.tpl'; $templatePath = File::symbolizePath($templatePath); $fileContents = File::get($templatePath); return TextParser::parse($fileContents, ['className' => Str::studly($scriptFilename), 'migrationCode' => $this->indent($code), 'namespace' => $pluginCodeObj->toUpdatesNamespace()]); }
protected function loadModelFromPost() { $pluginCodeObj = new PluginCode(Request::input('plugin_code')); $options = ['pluginCode' => $pluginCodeObj->toCode()]; $controller = Input::get('controller'); return $this->loadOrCreateBaseModel($controller, $options); }
public static function listPluginTables($pluginCode) { $pluginCodeObj = new PluginCode($pluginCode); $prefix = $pluginCodeObj->toDatabasePrefix(); $tables = self::getSchemaManager()->listTableNames(); return array_filter($tables, function ($item) use($prefix) { return Str::startsWith($item, $prefix); }); }
public function onPermissionsSave() { $pluginCodeObj = new PluginCode(Request::input('plugin_code')); $pluginCode = $pluginCodeObj->toCode(); $model = $this->loadOrCreateBaseModel($pluginCodeObj->toCode()); $model->setPluginCodeObj($pluginCodeObj); $model->fill($_POST); $model->save(); Flash::success(Lang::get('rainlab.builder::lang.permission.saved')); $result['builderResponseData'] = ['tabId' => $this->getTabId($pluginCode), 'tabTitle' => $model->getPluginName() . '/' . Lang::get('rainlab.builder::lang.permission.tab'), 'pluginCode' => $pluginCode]; return $result; }
public function getActivePluginVector() { $pluginCode = $this->getActivePluginCode(); try { if (strlen($pluginCode)) { $pluginCodeObj = new PluginCode($pluginCode); $path = $pluginCodeObj->toPluginInformationFilePath(); if (!File::isFile(File::symbolizePath($path))) { return null; } $plugins = PluginManager::instance()->getPlugins(); foreach ($plugins as $code => $plugin) { if ($code == $pluginCode) { return new PluginVector($plugin, $pluginCodeObj); } } } } catch (Exception $ex) { return null; } return null; }
public function listModelColumnNames() { $modelClass = $this->getModelClassDesignTime(); $key = md5('builder-global-model-list-' . $modelClass); $cached = Cache::get($key, false); if ($cached !== false && ($cached = @unserialize($cached)) !== false) { return $cached; } $pluginCodeObj = PluginCode::createFromNamespace($modelClass); $modelClassParts = explode('\\', $modelClass); // The full class name is already validated in PluginCode::createFromNamespace() $modelClass = array_pop($modelClassParts); $columnNames = ModelModel::getModelFields($pluginCodeObj, $modelClass); $result = []; foreach ($columnNames as $columnName) { $result[$columnName] = $columnName; } Cache::put($key, serialize($result), 1); return $result; }
public static function getPluginRegistryData($pluginCode, $subtype) { $pluginCodeObj = new PluginCode($pluginCode); $urlBase = $pluginCodeObj->toUrl() . '/'; $controllers = self::listPluginControllers($pluginCodeObj); $result = []; foreach ($controllers as $controler) { $controllerPath = strtolower(basename($controler)); $url = $urlBase . $controllerPath; $result[$url] = $url; } 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; }
protected function loadOrCreateLocalizationFromPost() { $pluginCodeObj = new PluginCode(Request::input('plugin_code')); $options = ['pluginCode' => $pluginCodeObj->toCode()]; $originalLanguage = Input::get('original_language'); return $this->loadOrCreateBaseModel($originalLanguage, $options); }