More changes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
.idea
|
.idea
|
||||||
nbproject/
|
nbproject/
|
||||||
|
tags
|
||||||
|
|
||||||
config/database.db
|
config/database.db
|
||||||
config/modules.ini
|
config/modules.ini
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Routes\RouteCollection as RouteCollection;
|
namespace App\Core\Generator;
|
||||||
|
|
||||||
class GeneratorController {
|
class GeneratorController {
|
||||||
|
|
||||||
@@ -51,6 +51,11 @@ class GeneratorController {
|
|||||||
private $controllerBase =
|
private $controllerBase =
|
||||||
<<<EOL
|
<<<EOL
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace {{NAMESPACE}};
|
||||||
|
|
||||||
|
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
|
||||||
|
|
||||||
class {{CONTROLLER}} {
|
class {{CONTROLLER}} {
|
||||||
|
|
||||||
function index(){
|
function index(){
|
||||||
@@ -65,23 +70,23 @@ class GeneratorController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show({{OBJECT}} \$instance){
|
function show({{OBJECT}} \{{OBJECT_LOWER}}){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit({{OBJECT}} \$instance){
|
function edit({{OBJECT}} \{{OBJECT_LOWER}}){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update({{OBJECT}} \$instance){
|
function update({{OBJECT}} \{{OBJECT_LOWER}}){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy({{OBJECT}} \$instance){
|
function destroy({{OBJECT}} \{{OBJECT_LOWER}}){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function purge({{OBJECT}} \$instance){
|
function purge({{OBJECT}} \{{OBJECT_LOWER}}){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,6 +96,9 @@ class GeneratorController {
|
|||||||
private $objectBase =
|
private $objectBase =
|
||||||
<<<EOL
|
<<<EOL
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace {{NAMESPACE}};
|
||||||
|
|
||||||
use ORM\Entity as Entity;
|
use ORM\Entity as Entity;
|
||||||
|
|
||||||
class {{OBJECT}} extends Entity {
|
class {{OBJECT}} extends Entity {
|
||||||
@@ -114,17 +122,30 @@ class GeneratorController {
|
|||||||
use Routes\RouteCollection as RouteCollection;
|
use Routes\RouteCollection as RouteCollection;
|
||||||
|
|
||||||
RouteCollection::group('/{{PLUGIN_NAME}}', function(){
|
RouteCollection::group('/{{PLUGIN_NAME}}', function(){
|
||||||
RouteCollection::get ('/', '{{CONTROLLER}}@index');
|
RouteCollection::get ('/', '\{{NAMESPACE}}\{{CONTROLLER}}@index');
|
||||||
RouteCollection::get ('/', '{{CONTROLLER}}@create');
|
RouteCollection::get ('/', '\{{NAMESPACE}}\{{CONTROLLER}}@create');
|
||||||
RouteCollection::post ('/', '{{CONTROLLER}}@store');
|
RouteCollection::post ('/', '\{{NAMESPACE}}\{{CONTROLLER}}@store');
|
||||||
RouteCollection::get ('/[i:id]', '{{CONTROLLER}}@show');
|
RouteCollection::get ('/[i:id]', '\{{NAMESPACE}}\{{CONTROLLER}}@show');
|
||||||
RouteCollection::get ('/[i:id]/edit', '{{CONTROLLER}}@edit');
|
RouteCollection::get ('/[i:id]/edit', '\{{NAMESPACE}}\{{CONTROLLER}}@edit');
|
||||||
RouteCollection::put ('/[i:id]/edit', '{{CONTROLLER}}@update');
|
RouteCollection::put ('/[i:id]/edit', '\{{NAMESPACE}}\{{CONTROLLER}}@update');
|
||||||
RouteCollection::delete('/[i:id]', '{{CONTROLLER}}@destroy');
|
RouteCollection::delete('/[i:id]', '\{{NAMESPACE}}\{{CONTROLLER}}@destroy');
|
||||||
});
|
});
|
||||||
EOL;
|
EOL;
|
||||||
|
|
||||||
|
private $ctagsHeader =
|
||||||
|
<<<EOL
|
||||||
|
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||||
|
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||||
|
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
|
||||||
|
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
|
||||||
|
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
|
||||||
|
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
|
||||||
|
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
|
||||||
|
!_TAG_PROGRAM_VERSION 0.0.0 /a3c87ab5/
|
||||||
|
EOL;
|
||||||
|
|
||||||
function createPluginFromTemplate($subname, $name){
|
function createPluginFromTemplate($subname, $name){
|
||||||
|
|
||||||
if (is_dir( DIR_APP.$subname . '/' . $name )){
|
if (is_dir( DIR_APP.$subname . '/' . $name )){
|
||||||
echo 'Treco ja existe';
|
echo 'Treco ja existe';
|
||||||
return;
|
return;
|
||||||
@@ -137,6 +158,7 @@ class GeneratorController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$plugin_name = $name;
|
$plugin_name = $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';
|
||||||
@@ -149,35 +171,58 @@ class GeneratorController {
|
|||||||
$this->migrationBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->migrationBase);
|
$this->migrationBase = str_replace("{{PLUGIN_NAME}}", $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("{{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("{{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("{{OBJECT}}", $object, $this->controllerBase);
|
$this->controllerBase = str_replace("{{OBJECT}}", $object, $this->controllerBase);
|
||||||
|
$this->controllerBase = str_replace("{{OBJECT_LOWER}}",strlower($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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function listRoutes(){
|
function listRoutes(){
|
||||||
foreach(RouteCollection::returnRoutes() as $route){
|
echo str_pad('VERB', 10, ' ', STR_PAD_BOTH) . "||";
|
||||||
//var_dump($route->_callback);continue;//die();
|
echo str_pad('URI' , 35, ' ', STR_PAD_BOTH) . "||";
|
||||||
echo implode($route->_verb , ', ') ." || $route->_uri || $route->_weight||";
|
echo str_pad('W', 5, ' ', STR_PAD_BOTH) . "||";
|
||||||
|
echo str_pad('FUNCTION', 60, ' ', STR_PAD_BOTH) . "\n";
|
||||||
|
echo str_pad('', 120, '-') . "\n";
|
||||||
|
foreach(\Routes\RouteCollection::returnRoutes() as $route){
|
||||||
|
echo str_pad(implode($route->_verb , ', '), 10, ' ', STR_PAD_BOTH) . "||";
|
||||||
|
echo str_pad($route->_uri, 35, ' ', STR_PAD_RIGHT) . "||";
|
||||||
|
echo str_pad($route->_weight, 5, ' ', STR_PAD_BOTH). "||";
|
||||||
if( gettype($route->_callback[0]) == 'object' ){
|
if( gettype($route->_callback[0]) == 'object' ){
|
||||||
echo 'Clousure ||';
|
echo str_pad('Clousure', 60, ' ', STR_PAD_RIGHT);
|
||||||
}else{
|
}else{
|
||||||
echo $route->_callback[0];
|
echo str_pad($route->_callback[0], 30, ' ', STR_PAD_RIGHT);
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
//file_put_contents('/tmp/Route.php', $this->routeBase);
|
}
|
||||||
//echo $this->objectBase;
|
|
||||||
echo APP_LANG;
|
function createTags(){
|
||||||
|
$outputs = shell_exec("grep -Rnsi '@ctag' . | sed s/\ //g | sed s/*@ctag/\ /g");
|
||||||
|
$outputs = preg_split('/\R/', $outputs);
|
||||||
|
$return = $this->ctagsHeader . "\n";
|
||||||
|
foreach($outputs as $output){
|
||||||
|
$line = explode(' ', str_replace('\\t', '', $output) );
|
||||||
|
@$line = $line[1] . "\t " . str_replace('./', '', explode(':', $line[0])[0]) . "\t ".$line[1] . "\n";
|
||||||
|
if( strpos($line, 'app/core/generator/GeneratorController.php') ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$return .= $line;
|
||||||
|
//echo "Generating: ".$line."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents(DIR_ROOT.'tags', $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
use Routes\RouteCollection as RouteCollection;
|
use Routes\RouteCollection as RouteCollection;
|
||||||
|
|
||||||
RouteCollection::group('/core', function(){
|
RouteCollection::cli('/', function(){
|
||||||
|
echo "/core/create/[h:subname]/[h:name]\n";
|
||||||
include_once 'GeneratorController.php';
|
|
||||||
|
|
||||||
RouteCollection::cli('/routes', function(){
|
|
||||||
last_class()->listRoutes();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RouteCollection::cli('/routes', '\App\Core\Generator\GeneratorController@listRoutes');
|
||||||
|
RouteCollection::cli('/create/tags', '\App\Core\Generator\GeneratorController@createTags');
|
||||||
|
RouteCollection::cli('/create/[h:subname]/[h:name]', '\App\Core\Generator\GeneratorController@createPluginFromTemplate');
|
||||||
|
|
||||||
|
RouteCollection::group('/core', function(){
|
||||||
|
|
||||||
RouteCollection::cli('/purge/[h:module]', function($module){
|
RouteCollection::cli('/purge/[h:module]', function($module){
|
||||||
echo "Purgin $module\n";
|
echo "Purgin $module\n";
|
||||||
@@ -19,6 +20,4 @@ RouteCollection::group('/core', function(){
|
|||||||
echo "Purging Everything\n";
|
echo "Purging Everything\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
RouteCollection::cli('/create/[h:subname]/[h:name]', 'GeneratorController@createPluginFromTemplate');
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -3,15 +3,14 @@
|
|||||||
use Routes\RouteCollection as RouteCollection;
|
use Routes\RouteCollection as RouteCollection;
|
||||||
use App\Core\Template\Output as Output;
|
use App\Core\Template\Output as Output;
|
||||||
|
|
||||||
include_once 'WellcomeController.php';
|
|
||||||
|
|
||||||
RouteCollection::add('GET','/', function(){
|
RouteCollection::add('GET','/', function(){
|
||||||
|
|
||||||
Output::setTemplate('');
|
Output::setTemplate('');
|
||||||
Output::setView('wellcome');
|
Output::setView('welcome');
|
||||||
Output::addValue('string', Array('welcome' => 'Bem vindo'));
|
Output::addValue('string', Array('welcome' => 'Bem vindo'));
|
||||||
Output::addValue('palavrinha', 'Oi');
|
Output::addValue('palavrinha', 'Oi');
|
||||||
Output::render();
|
Output::render();
|
||||||
});
|
});
|
||||||
|
|
||||||
RouteCollection::add('get', '/welcome', 'WellcomeController@welcome');
|
RouteCollection::get('/welcome', '\App\Core\Welcome\WelcomeController@welcome');
|
||||||
|
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Welcome;
|
||||||
|
|
||||||
|
use RR\Response as R;
|
||||||
|
|
||||||
|
class WelcomeController{
|
||||||
|
|
||||||
|
function welcome(){
|
||||||
|
R::json(Array('message' => \Lang::getString('welcome', 'welcome')))->send()->done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use RR\Response as R;
|
|
||||||
|
|
||||||
class WellcomeController{
|
|
||||||
|
|
||||||
function welcome(){
|
|
||||||
R::json(Array('message' => Lang::getString('welcome', 'welcome')))->send()->done();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-1
@@ -6,7 +6,7 @@ spl_autoload_register(function ($class_name) {
|
|||||||
|
|
||||||
$path[sizeof($path)-1] = '';
|
$path[sizeof($path)-1] = '';
|
||||||
|
|
||||||
$path = strtolower(implode(DIRECTORY_SEPARATOR, $path));
|
$path = strtolower(DIR_ROOT. implode(DIRECTORY_SEPARATOR, $path));
|
||||||
|
|
||||||
if(is_file($path . $fileName . '.php')){
|
if(is_file($path . $fileName . '.php')){
|
||||||
return include $path . $fileName . '.php';
|
return include $path . $fileName . '.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user