Changes to the Framework

This commit is contained in:
2020-11-02 16:01:27 -03:00
parent 47091f1754
commit ac574f3e53
91 changed files with 401 additions and 29524 deletions
+25 -17
View File
@@ -15,7 +15,8 @@ class GeneratorController {
<?php
use Schema\Wrapper as Wrapper;
use \App\Core\Sanity\MigratorController as Migrator;
function {{PLUGIN_NAME}}_upgrade(\$pluginversion) {
if (\$pluginversion < "0.0.1") {
\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
@@ -26,20 +27,20 @@ class GeneratorController {
\$table->addSoftDelete();
\$table->create();
Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.0");
Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.0");
return;
}
//if (\$pluginversion < "0.0.2") {
//\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
//Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.1");
//Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.1");
//return;
//}
}
function {{PLUGIN_NAME}}_rollback(\$pluginversion) {
if(\$pluginversion > "0.0.1"){
\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
\$table = Wrapper::get_table("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}");
\$table->drop();
return;
}
@@ -62,8 +63,8 @@ class GeneratorController {
namespace {{NAMESPACE}};
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
use \App\Core\Template\Output as Output;
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
class {{CONTROLLER}} {
@@ -88,7 +89,8 @@ class GeneratorController {
/**
* Create
* Render the main {{OBJECT}} formular
*
* Render the main {{OBJECT}} formulary
*/
function create(){
Output::setView('form', ['id' => 0]);
@@ -97,7 +99,8 @@ class GeneratorController {
/**
* Store
* Store the param on the database
*
* Store the param on the database
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function store({{OBJECT}} \${{OBJECT_LOWER}}){
@@ -106,7 +109,8 @@ class GeneratorController {
/**
* Show
* Render one register
*
* Render one register
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -116,17 +120,19 @@ class GeneratorController {
/**
* Edit
* Render the formular for a database {{OBJECT}}
*
* Render the formular for a database {{OBJECT}}
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function edit({{OBJECT}} \${{OBJECT_LOWER}}){
Output::setView('form', \${{OBJECT_LOWER}});
Output::render();
}
/**
* Update
* Store the changes of the param on the database
* Store the changes of the param on the database
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -136,16 +142,17 @@ class GeneratorController {
/**
* Destroy
* If the object has soft delete.
* If the object has soft delete.
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function destroy({{OBJECT}} \${{OBJECT_LOWER}}){
}
/**
* Purge
* Remove object even with soft delete.
* Remove object even with soft delete.
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -230,11 +237,11 @@ class GeneratorController {
private $formTemplate =
<<<EOL
{{@ if( {{id}} ): @}}
<form method="POST" action="{{ENDPOINT}}/{{id}}/edit">
<form method="POST" action="/{{ENDPOINT}}/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="{{ENDPOINT}}">
<form method="POST" action="/{{ENDPOINT}}">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
@@ -266,7 +273,7 @@ class GeneratorController {
mkdir(DIR_APP.$subname . "/" . $name . "/db", 0755, true);
mkdir(DIR_APP.$subname . "/" . $name . "/views", 0755, true);
}
$plugin_name = $name;
$namespace = "App\\".ucfirst($subname)."\\".ucfirst($name);
$plugin_name_pretty = ucwords(str_replace("_", " ", $name));
@@ -278,7 +285,8 @@ class GeneratorController {
file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/en.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);
$this->routeBase = str_replace("{{NAMESPACE}}", $namespace, $this->routeBase);
+1 -1
View File
@@ -3,7 +3,7 @@
use Routes\RouteCollection as RouteCollection;
RouteCollection::cli('/', function(){
echo "/core/create/[h:subname]/[h:name]\n";
echo "/create/[h:subname]/[h:name]\n";
});
RouteCollection::cli('/routes', '\App\Core\Generator\GeneratorController@listRoutes');