Ajusting core modules

This commit is contained in:
2022-01-23 19:15:33 +00:00
parent 1bbfcb3a89
commit a98e31ba9f
4 changed files with 12 additions and 38 deletions
+3 -5
View File
@@ -15,7 +15,6 @@ class GeneratorController {
<?php <?php
use Schema\Wrapper as Wrapper; use Schema\Wrapper as Wrapper;
use \App\Core\Sanity\MigratorController as Migrator;
function {{PLUGIN_NAME}}_upgrade(\$pluginversion) { function {{PLUGIN_NAME}}_upgrade(\$pluginversion) {
if (\$pluginversion < "0.0.1") { if (\$pluginversion < "0.0.1") {
@@ -27,20 +26,20 @@ class GeneratorController {
\$table->addSoftDelete(); \$table->addSoftDelete();
\$table->create(); \$table->create();
Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.0"); Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.0");
return; return;
} }
//if (\$pluginversion < "0.0.2") { //if (\$pluginversion < "0.0.2") {
//\$table = Wrapper::get_table("{{PLUGIN_NAME}}"); //\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
//Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.1"); //Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.1");
//return; //return;
//} //}
} }
function {{PLUGIN_NAME}}_rollback(\$pluginversion) { function {{PLUGIN_NAME}}_rollback(\$pluginversion) {
if(\$pluginversion > "0.0.1"){ if(\$pluginversion > "0.0.1"){
\$table = Wrapper::get_table("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}"); \$table = Wrapper::get_table("{{PLUGIN_NAME}}");
\$table->drop(); \$table->drop();
return; return;
} }
@@ -286,7 +285,6 @@ class GeneratorController {
file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/".APP_LANG.".php", $this->langBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/".APP_LANG.".php", $this->langBase);
$this->migrationBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->migrationBase); $this->migrationBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->migrationBase);
$this->migrationBase = str_replace("{{SUB_PLUGIN_NAME}}", $subname, $this->migrationBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/db/Migrate.php", $this->migrationBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/db/Migrate.php", $this->migrationBase);
$this->routeBase = str_replace("{{NAMESPACE}}", $namespace, $this->routeBase); $this->routeBase = str_replace("{{NAMESPACE}}", $namespace, $this->routeBase);
-5
View File
@@ -1,5 +0,0 @@
<?php
$lang['generator']['module_name'] = 'generator';
$lang['generator']['main_title'] = 'Module Generator';
-7
View File
@@ -1,7 +0,0 @@
<?php
$lang['generator']['module_name'] = 'wellcome';
$lang['generator']['main_title'] = 'Gerador de modulos!';
+6 -18
View File
@@ -99,7 +99,7 @@ class MigratorController {
$rdi = new \RecursiveDirectoryIterator(DIR_APP); $rdi = new \RecursiveDirectoryIterator(DIR_APP);
foreach (new \RecursiveIteratorIterator($rdi) as $file) { foreach (new \RecursiveIteratorIterator($rdi) as $file) {
if (strpos($file, 'version.php')) { if (strpos($file, 'version.php') && ! strpos($file, '.versi') ) {
$module_configs[] = str_replace('version.php', '', $file); $module_configs[] = str_replace('version.php', '', $file);
} }
} }
@@ -150,21 +150,12 @@ class MigratorController {
public function execute_plan() { public function execute_plan() {
$status = false; $status = false;
while (!$status) { while (!$status) {
$this->sort_plugins(); $this->sort_plugins();
$status = true; $status = true;
foreach ($this->install as $key => $item) { foreach ($this->install as $key => $item) {
/*
*
*
*
*/
$funname = explode('_', $item->name);
if(sizeof($funname) > 1){ unset($funname[0]); }
$funname = implode('_', $funname);
if (isset($item->require)) { if (isset($item->require)) {
if (!self::is_satisfy_array($item->require)) { if (!self::is_satisfy_array($item->require)) {
$status = false; $status = false;
@@ -172,16 +163,13 @@ class MigratorController {
} }
} }
if (!self::is_satisfy($item->name, $item->version)) { if (!self::is_satisfy($item->name, $item->version)) {
if (!function_exists($funname . '_upgrade')) { if (!function_exists($item->name . '_upgrade')) {
echo 'adsdsadasdsadassad';
$this->update_plugin_version($item->name, $item->version); $this->update_plugin_version($item->name, $item->version);
$this->upgrade[] = $item; $this->upgrade[] = $item;
$this->instaled[$item->name] = $item;
unset($this->install[$key]); unset($this->install[$key]);
continue; continue;
} }
$this->instaled[$item->name] = $item; call_user_func($item->name . '_upgrade', "0.0.0");
call_user_func($funname . '_upgrade', '0');
$this->upgrade[] = $this->instaled[$item->name]; $this->upgrade[] = $this->instaled[$item->name];
unset($this->install[$key]); unset($this->install[$key]);
$status = false; $status = false;
@@ -195,12 +183,12 @@ class MigratorController {
continue; continue;
} }
} }
if (!self::is_satisfy($funname, $item->version)) { if (!self::is_satisfy($item->name, $item->version)) {
if (!function_exists($item->name . '_upgrade')) { if (!function_exists($item->name . '_upgrade')) {
$this->update_plugin_version($item->name, $item->version); $this->update_plugin_version($item->name, $item->version);
continue; continue;
} }
call_user_func($funname . '_upgrade', $this->instaled[$item->name]->version); call_user_func($item->name . '_upgrade', $this->instaled[$item->name]->version);
$status = false; $status = false;
} }
} }