Link to the form must be with a absolute path

This commit is contained in:
2022-02-17 02:50:14 +00:00
parent a98e31ba9f
commit e063895ccb
+70 -63
View File
@@ -3,18 +3,19 @@
namespace App\Core\Generator; namespace App\Core\Generator;
class GeneratorController { class GeneratorController {
private $langBase = private $langBase =
<<<EOL <<<EOL
<?php <?php
\$lang["{{PLUGIN_NAME}}"]["module_name"] = "{{PLUGIN_NAME_PRETTY}}"; \$lang["{{PLUGIN_NAME}}"]["module_name"] = "{{PLUGIN_NAME_PRETTY}}";
EOL; EOL;
private $migrationBase = private $migrationBase =
<<<EOL <<<EOL
<?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") {
@@ -25,18 +26,18 @@ class GeneratorController {
\$table->addTimestamps(); \$table->addTimestamps();
\$table->addSoftDelete(); \$table->addSoftDelete();
\$table->create(); \$table->create();
Migrator::getInstance()->update_plugin_version("{{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("{{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("{{PLUGIN_NAME}}"); \$table = Wrapper::get_table("{{PLUGIN_NAME}}");
@@ -45,18 +46,18 @@ class GeneratorController {
} }
} }
EOL; EOL;
private $versionBase = private $versionBase =
<<<EOL <<<EOL
<?php <?php
\$plugin->name = "{{PLUGIN_NAME}}"; \$plugin->name = "{{PLUGIN_NAME}}";
\$plugin->version = "0.0.1"; \$plugin->version = "0.0.1";
//\$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] ); //\$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );
EOL; EOL;
private $controllerBase = private $controllerBase =
<<<EOL <<<EOL
<?php <?php
@@ -64,11 +65,11 @@ class GeneratorController {
use \App\Core\Template\Output as Output; use \App\Core\Template\Output as Output;
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}}; use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
class {{CONTROLLER}} { class {{CONTROLLER}} {
/** /**
* Index * Index
* Show the main {{OBJECT}} list * Show the main {{OBJECT}} list
*/ */
function index(){ function index(){
@@ -85,27 +86,27 @@ class GeneratorController {
Output::addValue('list', \$list ); Output::addValue('list', \$list );
Output::render(); Output::render();
} }
/** /**
* Create * Create
* *
* Render the main {{OBJECT}} formulary * Render the main {{OBJECT}} formulary
*/ */
function create(){ function create(){
Output::setView('form', ['id' => 0]); Output::setView('form', ['id' => 0]);
Output::render(); Output::render();
} }
/** /**
* Store * Store
* *
* Store the param on the database * Store the param on the database
* @param {{OBJECT}} \${{OBJECT_LOWER}} * @param {{OBJECT}} \${{OBJECT_LOWER}}
*/ */
function store({{OBJECT}} \${{OBJECT_LOWER}}){ function store({{OBJECT}} \${{OBJECT_LOWER}}){
} }
/** /**
* Show * Show
* *
@@ -114,9 +115,9 @@ class GeneratorController {
* @param {{OBJECT}} \${{OBJECT_LOWER}} * @param {{OBJECT}} \${{OBJECT_LOWER}}
*/ */
function show({{OBJECT}} \${{OBJECT_LOWER}}){ function show({{OBJECT}} \${{OBJECT_LOWER}}){
} }
/** /**
* Edit * Edit
* *
@@ -128,27 +129,27 @@ class GeneratorController {
Output::setView('form', \${{OBJECT_LOWER}}); Output::setView('form', \${{OBJECT_LOWER}});
Output::render(); Output::render();
} }
/** /**
* Update * Update
* Store the changes of the param on the database * Store the changes of the param on the database
* *
* @param {{OBJECT}} \${{OBJECT_LOWER}} * @param {{OBJECT}} \${{OBJECT_LOWER}}
*/ */
function update({{OBJECT}} \${{OBJECT_LOWER}}){ function update({{OBJECT}} \${{OBJECT_LOWER}}){
} }
/** /**
* Destroy * Destroy
* If the object has soft delete. * If the object has soft delete.
* *
* @param {{OBJECT}} \${{OBJECT_LOWER}} * @param {{OBJECT}} \${{OBJECT_LOWER}}
*/ */
function destroy({{OBJECT}} \${{OBJECT_LOWER}}){ function destroy({{OBJECT}} \${{OBJECT_LOWER}}){
} }
/** /**
* Purge * Purge
* Remove object even with soft delete. * Remove object even with soft delete.
@@ -156,13 +157,13 @@ class GeneratorController {
* @param {{OBJECT}} \${{OBJECT_LOWER}} * @param {{OBJECT}} \${{OBJECT_LOWER}}
*/ */
function purge({{OBJECT}} \${{OBJECT_LOWER}}){ function purge({{OBJECT}} \${{OBJECT_LOWER}}){
} }
} }
EOL; EOL;
private $objectBase = private $objectBase =
<<<EOL <<<EOL
<?php <?php
@@ -171,25 +172,31 @@ class GeneratorController {
use ORM\Entity as Entity; use ORM\Entity as Entity;
class {{OBJECT}} extends Entity { class {{OBJECT}} extends Entity {
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2); //const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
const _tableName = "{{TABLE_NAME}}"; const _tableName = "{{TABLE_NAME}}";
//const _properties = Array("id", "name"); //const _properties = Array("id", "name");
//const _timestamps = true; //const _timestamps = true;
//const _softdelete = true; //const _softdelete = true;
//const _connectionName = ""; //const _connectionName = "";
} }
EOL; EOL;
private $routeBase = private $routeBase =
<<<EOL <<<EOL
<?php <?php
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection; use Routes\RouteCollection as RouteCollection;
//Menu itens
RouteCollection::get('*', function() {
Output::addMenu('/{{PLUGIN_NAME}}', '{{PLUGIN_NAME}}', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
}, -10)->doIgnore();
RouteCollection::group("/{{PLUGIN_NAME}}", function(){ RouteCollection::group("/{{PLUGIN_NAME}}", function(){
RouteCollection::get ("/", "\{{NAMESPACE}}\{{CONTROLLER}}@index"); RouteCollection::get ("/", "\{{NAMESPACE}}\{{CONTROLLER}}@index");
RouteCollection::get ("/form", "\{{NAMESPACE}}\{{CONTROLLER}}@create"); RouteCollection::get ("/form", "\{{NAMESPACE}}\{{CONTROLLER}}@create");
@@ -200,10 +207,10 @@ class GeneratorController {
RouteCollection::delete("/[i:id]", "\{{NAMESPACE}}\{{CONTROLLER}}@destroy"); RouteCollection::delete("/[i:id]", "\{{NAMESPACE}}\{{CONTROLLER}}@destroy");
}); });
EOL; EOL;
private $indexTemplate = private $indexTemplate =
<<<EOL <<<EOL
<a href='{{ENDPOINT}}/form' >Adicionar </a> <a href='/{{ENDPOINT}}/form' >Adicionar </a>
<div class="table-responsive"> <div class="table-responsive">
<table class='table'> <table class='table'>
@@ -232,7 +239,7 @@ class GeneratorController {
</table> </table>
</div> </div>
EOL; EOL;
private $formTemplate = private $formTemplate =
<<<EOL <<<EOL
{{@ if( {{id}} ): @}} {{@ if( {{id}} ): @}}
@@ -246,9 +253,9 @@ class GeneratorController {
</form> </form>
EOL; EOL;
private $ctagsHeader = private $ctagsHeader =
<<<EOL <<<EOL
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
@@ -270,50 +277,50 @@ class GeneratorController {
mkdir(DIR_APP.$subname . "/" . $name . "/lang", 0755, true); mkdir(DIR_APP.$subname . "/" . $name . "/lang", 0755, true);
mkdir(DIR_APP.$subname . "/" . $name . "/classes", 0755, true); mkdir(DIR_APP.$subname . "/" . $name . "/classes", 0755, true);
mkdir(DIR_APP.$subname . "/" . $name . "/db", 0755, true); mkdir(DIR_APP.$subname . "/" . $name . "/db", 0755, true);
mkdir(DIR_APP.$subname . "/" . $name . "/views", 0755, true); mkdir(DIR_APP.$subname . "/" . $name . "/views", 0755, true);
} }
$plugin_name = $name; $plugin_name = $name;
$namespace = "App\\".ucfirst($subname)."\\".ucfirst($name); $namespace = "App\\".ucfirst($subname)."\\".ucfirst($name);
$plugin_name_pretty = ucwords(str_replace("_", " ", $name)); $plugin_name_pretty = ucwords(str_replace("_", " ", $name));
$object = ucfirst( $name ); $object = ucfirst( $name );
$controller = $object."Controller"; $controller = $object."Controller";
$this->langBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->langBase); $this->langBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->langBase);
$this->langBase = str_replace("{{PLUGIN_NAME_PRETTY}}", $plugin_name_pretty, $this->langBase); $this->langBase = str_replace("{{PLUGIN_NAME_PRETTY}}", $plugin_name_pretty, $this->langBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/en.php", $this->langBase); 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); 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}}", $subname."_".$plugin_name, $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);
$this->routeBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->routeBase); $this->routeBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->routeBase);
$this->routeBase = str_replace("{{CONTROLLER}}", $controller, $this->routeBase); $this->routeBase = str_replace("{{CONTROLLER}}", $controller, $this->routeBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/Routes.php", $this->routeBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/Routes.php", $this->routeBase);
$this->objectBase = str_replace("{{NAMESPACE}}", $namespace."\Classes", $this->objectBase); $this->objectBase = str_replace("{{NAMESPACE}}", $namespace."\Classes", $this->objectBase);
$this->objectBase = str_replace("{{OBJECT}}", $object, $this->objectBase); $this->objectBase = str_replace("{{OBJECT}}", $object, $this->objectBase);
$this->objectBase = str_replace("{{TABLE_NAME}}", $name, $this->objectBase); $this->objectBase = str_replace("{{TABLE_NAME}}", $name, $this->objectBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/classes/$object.php", $this->objectBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/classes/$object.php", $this->objectBase);
$this->controllerBase = str_replace("{{NAMESPACE}}", $namespace, $this->controllerBase); $this->controllerBase = str_replace("{{NAMESPACE}}", $namespace, $this->controllerBase);
$this->controllerBase = str_replace("{{OBJECT}}", $object, $this->controllerBase); $this->controllerBase = str_replace("{{OBJECT}}", $object, $this->controllerBase);
$this->controllerBase = str_replace("{{OBJECT_LOWER}}",strtolower($object), $this->controllerBase); $this->controllerBase = str_replace("{{OBJECT_LOWER}}",strtolower($object), $this->controllerBase);
$this->controllerBase = str_replace("{{CONTROLLER}}", $controller, $this->controllerBase); $this->controllerBase = str_replace("{{CONTROLLER}}", $controller, $this->controllerBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/$controller.php", $this->controllerBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/$controller.php", $this->controllerBase);
$this->versionBase = str_replace("{{PLUGIN_NAME}}", $subname."_".$plugin_name, $this->versionBase); $this->versionBase = str_replace("{{PLUGIN_NAME}}", $subname."_".$plugin_name, $this->versionBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/version.php", $this->versionBase); file_put_contents(DIR_APP.$subname . "/" . $name . "/version.php", $this->versionBase);
$this->indexTemplate = str_replace("{{ENDPOINT}}", $plugin_name, $this->indexTemplate); $this->indexTemplate = str_replace("{{ENDPOINT}}", $plugin_name, $this->indexTemplate);
file_put_contents(DIR_APP.$subname . "/" . $name . "/views/index.mustache", $this->indexTemplate); file_put_contents(DIR_APP.$subname . "/" . $name . "/views/index.mustache", $this->indexTemplate);
$this->formTemplate = str_replace("{{ENDPOINT}}", $plugin_name, $this->formTemplate); $this->formTemplate = str_replace("{{ENDPOINT}}", $plugin_name, $this->formTemplate);
file_put_contents(DIR_APP.$subname . "/" . $name . "/views/form.mustache", $this->formTemplate); file_put_contents(DIR_APP.$subname . "/" . $name . "/views/form.mustache", $this->formTemplate);
} }
function listRoutes(){ function listRoutes(){
echo str_pad("VERB", 10, " ", STR_PAD_BOTH) . "||"; echo str_pad("VERB", 10, " ", STR_PAD_BOTH) . "||";
echo str_pad("URI" , 35, " ", STR_PAD_BOTH) . "||"; echo str_pad("URI" , 35, " ", STR_PAD_BOTH) . "||";
@@ -348,7 +355,7 @@ class GeneratorController {
} }
file_put_contents(DIR_ROOT."tags", $return); file_put_contents(DIR_ROOT."tags", $return);
} }
} }