protected function initPluginStructure()
 {
     $basePath = $this->getPluginPath();
     $defaultLanguage = LocalizationModel::getDefaultLanguage();
     $structure = [$basePath . '/Plugin.php' => 'plugin.php.tpl', $basePath . '/updates/version.yaml' => 'version.yaml.tpl', $basePath . '/classes', $basePath . '/lang/' . $defaultLanguage . '/lang.php' => 'lang.php.tpl'];
     $variables = ['authorNamespace' => $this->author_namespace, 'pluginNamespace' => $this->namespace, 'pluginNameSanitized' => $this->sanitizePHPString($this->localizedName), 'pluginDescriptionSanitized' => $this->sanitizePHPString($this->localizedDescription)];
     $generator = new FilesystemGenerator('$', $structure, '$/rainlab/builder/classes/pluginbasemodel/templates');
     $generator->setVariables($variables);
     $generator->generate();
 }
 public function onLanguageCreateString()
 {
     $stringKey = trim(Request::input('key'));
     $stringValue = trim(Request::input('value'));
     $pluginCodeObj = new PluginCode(Request::input('plugin_code'));
     $pluginCode = $pluginCodeObj->toCode();
     $options = ['pluginCode' => $pluginCode];
     $defaultLanguage = LocalizationModel::getDefaultLanguage();
     if (LocalizationModel::languageFileExists($pluginCode, $defaultLanguage)) {
         $model = $this->loadOrCreateBaseModel($defaultLanguage, $options);
     } else {
         $model = LocalizationModel::initModel($pluginCode, $defaultLanguage);
     }
     $newStringKey = $model->createStringAndSave($stringKey, $stringValue);
     $pluginCode = $pluginCodeObj->toCode();
     return ['localizationData' => ['key' => $newStringKey, 'value' => $stringValue], 'registryData' => ['strings' => LocalizationModel::getPluginRegistryData($pluginCode, null), 'sections' => LocalizationModel::getPluginRegistryData($pluginCode, 'sections')]];
 }