@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT))) |
27 | 27 | { |
28 | 28 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
29 | - } |
|
30 | - else |
|
29 | + } else |
|
31 | 30 | { |
32 | 31 | $this->stub = $stub; |
33 | 32 | |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | if ($fileToCompile->cached) |
59 | 58 | { |
60 | 59 | File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
61 | - } |
|
62 | - else |
|
60 | + } else |
|
63 | 61 | { |
64 | 62 | File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
65 | 63 | File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -89,8 +87,7 @@ discard block |
||
89 | 87 | { |
90 | 88 | $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
91 | 89 | $firstIteration = false; |
92 | - } |
|
93 | - else |
|
90 | + } else |
|
94 | 91 | { |
95 | 92 | $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
96 | 93 | } |
@@ -124,8 +121,7 @@ discard block |
||
124 | 121 | $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
125 | 122 | $firstIteration = false; |
126 | 123 | |
127 | - } |
|
128 | - else |
|
124 | + } else |
|
129 | 125 | { |
130 | 126 | $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
131 | 127 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null) |
26 | 26 | { |
27 | - if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT))) |
|
27 | + if (File::exists(base_path('scaffolder-config/cache/view_index_'.$hash.self::CACHE_EXT))) |
|
28 | 28 | { |
29 | 29 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
30 | 30 | } |
@@ -53,22 +53,22 @@ discard block |
||
53 | 53 | */ |
54 | 54 | protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile) |
55 | 55 | { |
56 | - $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ; |
|
56 | + $folder = PathParser::parse($scaffolderConfig->paths->views).strtolower($modelName); |
|
57 | 57 | |
58 | 58 | // create folder directory |
59 | 59 | Directory::createIfNotExists($folder, 0755, true); |
60 | 60 | |
61 | - $path = $folder . '/index.blade.php'; |
|
61 | + $path = $folder.'/index.blade.php'; |
|
62 | 62 | |
63 | 63 | // Store in cache |
64 | 64 | if ($fileToCompile->cached) |
65 | 65 | { |
66 | - File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
66 | + File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
70 | - File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
|
71 | - File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
70 | + File::put(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $compiled); |
|
71 | + File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $path; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | { |
94 | 94 | if ($firstIteration) |
95 | 95 | { |
96 | - $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
|
96 | + $fields .= sprintf("{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name); |
|
97 | 97 | $firstIteration = false; |
98 | 98 | } |
99 | 99 | else |
100 | 100 | { |
101 | - $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
|
101 | + $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | { |
128 | 128 | if ($firstIteration) |
129 | 129 | { |
130 | - $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
|
130 | + $fields .= sprintf("<th>%s</th>".PHP_EOL, ucfirst($field->name)); |
|
131 | 131 | $firstIteration = false; |
132 | 132 | |
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
136 | - $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
|
136 | + $fields .= sprintf("\t\t\t<th>%s</th>".PHP_EOL, ucfirst($field->name)); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
@@ -16,8 +16,7 @@ |
||
16 | 16 | if ($fieldData->type->ui == 'text') |
17 | 17 | { |
18 | 18 | return '{!! Form::text(\'%s\', (isset($model)) ? $model->' . $fieldData->name . ' : null) !!}'; |
19 | - } |
|
20 | - elseif ($fieldData->type->ui == 'textarea') |
|
19 | + } elseif ($fieldData->type->ui == 'textarea') |
|
21 | 20 | { |
22 | 21 | return '{!! Form::textarea(\'%s\', (isset($model)) ? $model->' . $fieldData->name . ' : null) !!}'; |
23 | 22 | } |
@@ -15,11 +15,11 @@ |
||
15 | 15 | { |
16 | 16 | if ($fieldData->type->ui == 'text') |
17 | 17 | { |
18 | - return '{!! Form::text(\'%s\', (isset($model)) ? $model->' . $fieldData->name . ' : null) !!}'; |
|
18 | + return '{!! Form::text(\'%s\', (isset($model)) ? $model->'.$fieldData->name.' : null) !!}'; |
|
19 | 19 | } |
20 | 20 | elseif ($fieldData->type->ui == 'textarea') |
21 | 21 | { |
22 | - return '{!! Form::textarea(\'%s\', (isset($model)) ? $model->' . $fieldData->name . ' : null) !!}'; |
|
22 | + return '{!! Form::textarea(\'%s\', (isset($model)) ? $model->'.$fieldData->name.' : null) !!}'; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -18,33 +18,26 @@ |
||
18 | 18 | if (head($path) == 'app') |
19 | 19 | { |
20 | 20 | $path = app_path(last($path)); |
21 | - } |
|
22 | - elseif (head($path) == 'base') |
|
21 | + } elseif (head($path) == 'base') |
|
23 | 22 | { |
24 | 23 | $path = base_path(last($path)); |
25 | - } |
|
26 | - elseif (head($path) == 'config') |
|
24 | + } elseif (head($path) == 'config') |
|
27 | 25 | { |
28 | 26 | $path = config_path(last($path)); |
29 | - } |
|
30 | - elseif (head($path) == 'database') |
|
27 | + } elseif (head($path) == 'database') |
|
31 | 28 | { |
32 | 29 | $path = database_path(last($path)); |
33 | - } |
|
34 | - elseif (head($path) == 'public') |
|
30 | + } elseif (head($path) == 'public') |
|
35 | 31 | { |
36 | 32 | $path = public_path(last($path)); |
37 | - } |
|
38 | - elseif (head($path) == 'storage') |
|
33 | + } elseif (head($path) == 'storage') |
|
39 | 34 | { |
40 | 35 | $path = storage_path(last($path)); |
41 | - } |
|
42 | - else |
|
36 | + } else |
|
43 | 37 | { |
44 | 38 | $path = head($path); |
45 | 39 | } |
46 | - } |
|
47 | - else |
|
40 | + } else |
|
48 | 41 | { |
49 | 42 | $path = head($path); |
50 | 43 | } |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function show($id) |
46 | - { |
|
47 | - return 'Not implemented'; |
|
48 | - } |
|
46 | + { |
|
47 | + return 'Not implemented'; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | public function edit($id) |
51 | - { |
|
52 | - $model = {{class_name}}::find($id); |
|
51 | + { |
|
52 | + $model = {{class_name}}::find($id); |
|
53 | 53 | |
54 | 54 | return view('{{class_name_lw}}.edit')->with('model', $model); |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | 57 | public function update($id, Request $request) |
58 | - { |
|
58 | + { |
|
59 | 59 | $this->validate($request, [ |
60 | 60 | |
61 | 61 | {{validations}} |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | |
64 | 64 | {{class_name}}::find($id)->fill($request->all())->save(); |
65 | 65 | |
66 | - return response()->json(['message' => 'ok']); |
|
67 | - } |
|
66 | + return response()->json(['message' => 'ok']); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | public function destroy($id) |
70 | - { |
|
70 | + { |
|
71 | 71 | {{class_name}}::destroy($id); |
72 | 72 | |
73 | - return response()->json(['message' => 'ok']); |
|
74 | - } |
|
73 | + return response()->json(['message' => 'ok']); |
|
74 | + } |
|
75 | 75 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function get{{class_name}}s() |
18 | 18 | { |
19 | 19 | return Datatables::of({{class_name}}::select('*')) |
20 | - ->addColumn('action', function ($model) { |
|
20 | + ->addColumn('action', function($model) { |
|
21 | 21 | return ' |
22 | 22 | <a href="/{{route_prefix}}/{{class_name_lw}}/'.$model->{{primaryKey}}.'/edit"><i class="material-icons">create</i></a> |
23 | 23 | <a href="#" onclick="deleteModel(\''.$model->{{primaryKey}}.'\')"><i class="material-icons">delete</i></a>'; |
@@ -3,14 +3,14 @@ |
||
3 | 3 | use Illuminate\Database\Schema\Blueprint; |
4 | 4 | use Illuminate\Database\Migrations\Migration; |
5 | 5 | |
6 | -class Create{{class_name}}sTable extends Migration |
|
6 | +class Create {{class_name}}sTable extends Migration |
|
7 | 7 | { |
8 | 8 | /** |
9 | 9 | * Run the migrations. |
10 | 10 | */ |
11 | 11 | public function up() |
12 | 12 | { |
13 | - Schema::create('{{table_name}}s', function (Blueprint $table) { |
|
13 | + Schema::create('{{table_name}}s', function(Blueprint $table) { |
|
14 | 14 | |
15 | 15 | {{fields}} |
16 | 16 | }); |
@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | |
28 | 28 | array_walk_recursive($models, function (&$item) |
29 | 29 | { |
30 | - if ($item == 'true') $item = true; |
|
31 | - elseif ($item == 'false') $item = false; |
|
30 | + if ($item == 'true') { |
|
31 | + $item = true; |
|
32 | + } elseif ($item == 'false') { |
|
33 | + $item = false; |
|
34 | + } |
|
32 | 35 | }); |
33 | 36 | |
34 | 37 | // Generate app.json |
@@ -51,8 +54,11 @@ discard block |
||
51 | 54 | |
52 | 55 | array_walk_recursive($models, function (&$item) |
53 | 56 | { |
54 | - if ($item == 'true') $item = true; |
|
55 | - elseif ($item == 'false') $item = false; |
|
57 | + if ($item == 'true') { |
|
58 | + $item = true; |
|
59 | + } elseif ($item == 'false') { |
|
60 | + $item = false; |
|
61 | + } |
|
56 | 62 | }); |
57 | 63 | |
58 | 64 | // Generate app.json |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | use Illuminate\Http\Request; |
4 | 4 | use Illuminate\Support\Facades\File; |
5 | 5 | |
6 | -Route::get('scaffolder/generator', function () |
|
6 | +Route::get('scaffolder/generator', function() |
|
7 | 7 | { |
8 | 8 | return view('scaffolder::generator'); |
9 | 9 | }); |
10 | 10 | |
11 | -Route::post('scaffolder/add-model', function (Request $request) |
|
11 | +Route::post('scaffolder/add-model', function(Request $request) |
|
12 | 12 | { |
13 | 13 | return view('scaffolder::partials.model', ['modelId' => $request->input('modelId')]); |
14 | 14 | }); |
15 | 15 | |
16 | -Route::post('scaffolder/add-field', function (Request $request) |
|
16 | +Route::post('scaffolder/add-field', function(Request $request) |
|
17 | 17 | { |
18 | 18 | return view('scaffolder::partials.field', [ |
19 | 19 | 'modelId' => $request->input('modelId'), |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | ]); |
22 | 22 | }); |
23 | 23 | |
24 | -Route::post('scaffolder/generate', function (Request $request) |
|
24 | +Route::post('scaffolder/generate', function(Request $request) |
|
25 | 25 | { |
26 | 26 | $models = $request->only('models'); |
27 | 27 | |
28 | - array_walk_recursive($models, function (&$item) |
|
28 | + array_walk_recursive($models, function(&$item) |
|
29 | 29 | { |
30 | 30 | if ($item == 'true') $item = true; |
31 | 31 | elseif ($item == 'false') $item = false; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | { |
41 | 41 | $modelName = $model['modelName']; |
42 | 42 | array_shift($model); |
43 | - File::put(base_path('scaffolder-config/models/' . $modelName . '.json'), |
|
43 | + File::put(base_path('scaffolder-config/models/'.$modelName.'.json'), |
|
44 | 44 | json_encode($model, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
45 | 45 | } |
46 | 46 | }); |
47 | 47 | |
48 | -Route::post('scaffolder/generate-and-execute', function (Request $request) |
|
48 | +Route::post('scaffolder/generate-and-execute', function(Request $request) |
|
49 | 49 | { |
50 | 50 | $models = $request->only('models'); |
51 | 51 | |
52 | - array_walk_recursive($models, function (&$item) |
|
52 | + array_walk_recursive($models, function(&$item) |
|
53 | 53 | { |
54 | 54 | if ($item == 'true') $item = true; |
55 | 55 | elseif ($item == 'false') $item = false; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $modelName = $model['modelName']; |
66 | 66 | array_shift($model); |
67 | - File::put(base_path('scaffolder-config/models/' . $modelName . '.json'), |
|
67 | + File::put(base_path('scaffolder-config/models/'.$modelName.'.json'), |
|
68 | 68 | json_encode($model, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
69 | 69 | } |
70 | 70 |
@@ -39,11 +39,8 @@ |
||
39 | 39 | use Scaffolder\Support\Json; |
40 | 40 | use Scaffolder\Support\Arrays; |
41 | 41 | use Scaffolder\Support\CamelCase; |
42 | -use Scaffolder\Themes\IScaffolderThemeLayouts; |
|
43 | -use Scaffolder\Themes\IScaffolderThemeViews; |
|
44 | 42 | use Scaffolder\Compilers\Support\PathParser; |
45 | - |
|
46 | -use stdClass ; |
|
43 | +use stdClass; |
|
47 | 44 | |
48 | 45 | class GeneratorCommand extends Command |
49 | 46 | { |
@@ -47,334 +47,334 @@ discard block |
||
47 | 47 | |
48 | 48 | class GeneratorCommand extends Command |
49 | 49 | { |
50 | - protected $signature = 'scaffolder:generate {app=laravel} {--c|clear-all : Clears cache and drafts before generate}'; |
|
50 | + protected $signature = 'scaffolder:generate {app=laravel} {--c|clear-all : Clears cache and drafts before generate}'; |
|
51 | 51 | |
52 | - protected $description = 'Scaffold an application'; |
|
52 | + protected $description = 'Scaffold an application'; |
|
53 | 53 | |
54 | - protected $stubsDirectory; |
|
54 | + protected $stubsDirectory; |
|
55 | 55 | |
56 | - public function __construct() |
|
57 | - { |
|
58 | - parent::__construct(); |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + parent::__construct(); |
|
59 | 59 | |
60 | - $this->stubsDirectory = __DIR__ . '/../../../stubs/'; |
|
61 | - } |
|
60 | + $this->stubsDirectory = __DIR__ . '/../../../stubs/'; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Execute the Command. |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function handle() |
|
68 | - { |
|
69 | - // check if is to clear cache |
|
70 | - if($this->option('clear-all')){ |
|
71 | - $this->call('scaffolder:clear'); |
|
72 | - } |
|
63 | + /** |
|
64 | + * Execute the Command. |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function handle() |
|
68 | + { |
|
69 | + // check if is to clear cache |
|
70 | + if($this->option('clear-all')){ |
|
71 | + $this->call('scaffolder:clear'); |
|
72 | + } |
|
73 | 73 | |
74 | - // Create drafs directory |
|
75 | - Directory::createIfNotExists(base_path('drafts')); |
|
74 | + // Create drafs directory |
|
75 | + Directory::createIfNotExists(base_path('drafts')); |
|
76 | 76 | |
77 | - switch ($this->argument('app')) { |
|
78 | - case 'api': |
|
79 | - $this->handleApi(); |
|
80 | - break; |
|
77 | + switch ($this->argument('app')) { |
|
78 | + case 'api': |
|
79 | + $this->handleApi(); |
|
80 | + break; |
|
81 | 81 | |
82 | - case 'angularjs': |
|
83 | - $this->handleAngularJs(); |
|
84 | - break; |
|
82 | + case 'angularjs': |
|
83 | + $this->handleAngularJs(); |
|
84 | + break; |
|
85 | 85 | |
86 | - case 'ionic': |
|
87 | - # code... |
|
88 | - break; |
|
86 | + case 'ionic': |
|
87 | + # code... |
|
88 | + break; |
|
89 | 89 | |
90 | - case 'android': |
|
91 | - #TODO implement code... |
|
92 | - break; |
|
90 | + case 'android': |
|
91 | + #TODO implement code... |
|
92 | + break; |
|
93 | 93 | |
94 | - case 'ios': |
|
95 | - #TODO implement code... |
|
96 | - break; |
|
94 | + case 'ios': |
|
95 | + #TODO implement code... |
|
96 | + break; |
|
97 | 97 | |
98 | - case 'blade': |
|
99 | - $this->handleBlade(); |
|
100 | - break; |
|
98 | + case 'blade': |
|
99 | + $this->handleBlade(); |
|
100 | + break; |
|
101 | 101 | |
102 | - default: |
|
103 | - $this->handleLaravel(); |
|
104 | - break; |
|
105 | - } |
|
102 | + default: |
|
103 | + $this->handleLaravel(); |
|
104 | + break; |
|
105 | + } |
|
106 | 106 | |
107 | 107 | |
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * API Generation command for API files. |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - private function handleApi(){ |
|
115 | - // Get all the models |
|
116 | - $modelsData = $this->getAllModelsData(); |
|
117 | - |
|
118 | - // Start progress bar |
|
119 | - $this->output->progressStart(count($modelsData)); |
|
120 | - |
|
121 | - // Get app config |
|
122 | - $scaffolderConfig = $this->getScaffolderConfig(); |
|
123 | - |
|
124 | - // Compiler output |
|
125 | - $modelCompilerOutput = []; |
|
126 | - $controllerCompilerOutput = []; |
|
127 | - $migrationCompilerOutput = []; |
|
128 | - |
|
129 | - // Sidenav links |
|
130 | - $sidenavLinks = []; |
|
131 | - |
|
132 | - // Compiled routes |
|
133 | - $compiledRoutes = ''; |
|
134 | - |
|
135 | - // Create route compiler |
|
136 | - $routeCompiler = new RouteCompiler($scaffolderConfig); |
|
137 | - |
|
138 | - // Create models directory |
|
139 | - Directory::createIfNotExists(app_path('Models')); |
|
140 | - |
|
141 | - // Create drafts directory |
|
142 | - // migrations |
|
143 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->migrations), 0755, true); |
|
144 | - // models |
|
145 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->models), 0755, true); |
|
146 | - // repositories |
|
147 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->repositories), 0755, true); |
|
148 | - // controllers |
|
149 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->controllers), 0755, true); |
|
150 | - // routes |
|
151 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->routes), 0755, true); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * API Generation command for API files. |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + private function handleApi(){ |
|
115 | + // Get all the models |
|
116 | + $modelsData = $this->getAllModelsData(); |
|
117 | + |
|
118 | + // Start progress bar |
|
119 | + $this->output->progressStart(count($modelsData)); |
|
120 | + |
|
121 | + // Get app config |
|
122 | + $scaffolderConfig = $this->getScaffolderConfig(); |
|
123 | + |
|
124 | + // Compiler output |
|
125 | + $modelCompilerOutput = []; |
|
126 | + $controllerCompilerOutput = []; |
|
127 | + $migrationCompilerOutput = []; |
|
128 | + |
|
129 | + // Sidenav links |
|
130 | + $sidenavLinks = []; |
|
131 | + |
|
132 | + // Compiled routes |
|
133 | + $compiledRoutes = ''; |
|
134 | + |
|
135 | + // Create route compiler |
|
136 | + $routeCompiler = new RouteCompiler($scaffolderConfig); |
|
137 | + |
|
138 | + // Create models directory |
|
139 | + Directory::createIfNotExists(app_path('Models')); |
|
140 | + |
|
141 | + // Create drafts directory |
|
142 | + // migrations |
|
143 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->migrations), 0755, true); |
|
144 | + // models |
|
145 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->models), 0755, true); |
|
146 | + // repositories |
|
147 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->repositories), 0755, true); |
|
148 | + // controllers |
|
149 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->controllers), 0755, true); |
|
150 | + // routes |
|
151 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->routes), 0755, true); |
|
152 | 152 | |
153 | - // Iterate over models data |
|
154 | - foreach ($modelsData as $modelData) |
|
155 | - { |
|
153 | + // Iterate over models data |
|
154 | + foreach ($modelsData as $modelData) |
|
155 | + { |
|
156 | 156 | |
157 | - // Create Compilers |
|
158 | - $stubModel = null; |
|
159 | - $stubController = null; |
|
157 | + // Create Compilers |
|
158 | + $stubModel = null; |
|
159 | + $stubController = null; |
|
160 | 160 | |
161 | - if ($modelData->tableName == "file") { |
|
162 | - $stubModel = 'Model/FileModel.php'; |
|
163 | - $stubController = 'Controller/FileController.php'; |
|
164 | - } |
|
165 | - |
|
166 | - $modelCompiler = new ModelCompiler($scaffolderConfig, $modelData, $stubModel); |
|
167 | - $migrationCompiler = new MigrationCompiler($scaffolderConfig, $modelData); |
|
168 | - $controllerCompiler = new ControllerCompiler($scaffolderConfig, $modelData, $stubController); |
|
169 | - |
|
170 | - // Compile stubs |
|
171 | - array_push($modelCompilerOutput, $modelCompiler->compile()); |
|
172 | - array_push($controllerCompilerOutput, $controllerCompiler->compile()); |
|
173 | - array_push($migrationCompilerOutput, $migrationCompiler->compile()); |
|
161 | + if ($modelData->tableName == "file") { |
|
162 | + $stubModel = 'Model/FileModel.php'; |
|
163 | + $stubController = 'Controller/FileController.php'; |
|
164 | + } |
|
165 | + |
|
166 | + $modelCompiler = new ModelCompiler($scaffolderConfig, $modelData, $stubModel); |
|
167 | + $migrationCompiler = new MigrationCompiler($scaffolderConfig, $modelData); |
|
168 | + $controllerCompiler = new ControllerCompiler($scaffolderConfig, $modelData, $stubController); |
|
169 | + |
|
170 | + // Compile stubs |
|
171 | + array_push($modelCompilerOutput, $modelCompiler->compile()); |
|
172 | + array_push($controllerCompilerOutput, $controllerCompiler->compile()); |
|
173 | + array_push($migrationCompilerOutput, $migrationCompiler->compile()); |
|
174 | 174 | |
175 | - $compiledRoutes .= $routeCompiler->replaceResource($modelData); |
|
176 | - // |
|
177 | - |
|
178 | - // Add entity link |
|
179 | - array_push($sidenavLinks, $modelData->modelName); |
|
180 | - |
|
181 | - // Advance progress |
|
182 | - $this->output->progressAdvance(); |
|
183 | - } |
|
184 | - |
|
185 | - // Store compiled routes |
|
186 | - $routeCompiler->compileGroup($compiledRoutes); |
|
187 | - |
|
188 | - // Finish progress |
|
189 | - $this->output->progressFinish(); |
|
190 | - |
|
191 | - // Summary |
|
192 | - $this->comment('- Files created'); |
|
193 | - |
|
194 | - $this->comment('- - Controllers'); |
|
195 | - foreach ($controllerCompilerOutput as $controllerFile) |
|
196 | - { |
|
197 | - $this->info('- - - ' . $controllerFile); |
|
198 | - } |
|
199 | - |
|
200 | - $this->comment('- - Migrations'); |
|
201 | - foreach ($migrationCompilerOutput as $migrationFile) |
|
202 | - { |
|
203 | - $this->info('- - - ' . $migrationFile); |
|
204 | - } |
|
205 | - |
|
206 | - $this->comment('- - Models'); |
|
207 | - foreach ($modelCompilerOutput as $modelFile) |
|
208 | - { |
|
209 | - $this->info('- - - ' . $modelFile); |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Code Generation command for AngularJs Material design files. |
|
215 | - * @return void |
|
216 | - */ |
|
217 | - private function handleAngularJs(){ |
|
218 | - // Get all the models |
|
219 | - $modelsData = $this->getAllModelsData(); |
|
220 | - |
|
221 | - // Start progress bar |
|
222 | - $this->output->progressStart((count($modelsData) * 2) + (count($modelsData) * 2 * 4) + 1); |
|
223 | - |
|
224 | - // Get app config |
|
225 | - $scaffolderConfig = $this->getScaffolderConfig(); |
|
226 | - |
|
227 | - // Compiler output |
|
228 | - $resourceCompilerOutput = []; |
|
229 | - $moduleCompilerOutput = []; |
|
230 | - $translateCompilerOutput = []; |
|
231 | - // register |
|
232 | - $registerModuleCompilerOutput = []; |
|
233 | - $registerControllerCompilerOutput = []; |
|
234 | - $registerTemplateCompilerOutput = []; |
|
175 | + $compiledRoutes .= $routeCompiler->replaceResource($modelData); |
|
176 | + // |
|
177 | + |
|
178 | + // Add entity link |
|
179 | + array_push($sidenavLinks, $modelData->modelName); |
|
180 | + |
|
181 | + // Advance progress |
|
182 | + $this->output->progressAdvance(); |
|
183 | + } |
|
184 | + |
|
185 | + // Store compiled routes |
|
186 | + $routeCompiler->compileGroup($compiledRoutes); |
|
187 | + |
|
188 | + // Finish progress |
|
189 | + $this->output->progressFinish(); |
|
190 | + |
|
191 | + // Summary |
|
192 | + $this->comment('- Files created'); |
|
193 | + |
|
194 | + $this->comment('- - Controllers'); |
|
195 | + foreach ($controllerCompilerOutput as $controllerFile) |
|
196 | + { |
|
197 | + $this->info('- - - ' . $controllerFile); |
|
198 | + } |
|
199 | + |
|
200 | + $this->comment('- - Migrations'); |
|
201 | + foreach ($migrationCompilerOutput as $migrationFile) |
|
202 | + { |
|
203 | + $this->info('- - - ' . $migrationFile); |
|
204 | + } |
|
205 | + |
|
206 | + $this->comment('- - Models'); |
|
207 | + foreach ($modelCompilerOutput as $modelFile) |
|
208 | + { |
|
209 | + $this->info('- - - ' . $modelFile); |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Code Generation command for AngularJs Material design files. |
|
215 | + * @return void |
|
216 | + */ |
|
217 | + private function handleAngularJs(){ |
|
218 | + // Get all the models |
|
219 | + $modelsData = $this->getAllModelsData(); |
|
220 | + |
|
221 | + // Start progress bar |
|
222 | + $this->output->progressStart((count($modelsData) * 2) + (count($modelsData) * 2 * 4) + 1); |
|
223 | + |
|
224 | + // Get app config |
|
225 | + $scaffolderConfig = $this->getScaffolderConfig(); |
|
226 | + |
|
227 | + // Compiler output |
|
228 | + $resourceCompilerOutput = []; |
|
229 | + $moduleCompilerOutput = []; |
|
230 | + $translateCompilerOutput = []; |
|
231 | + // register |
|
232 | + $registerModuleCompilerOutput = []; |
|
233 | + $registerControllerCompilerOutput = []; |
|
234 | + $registerTemplateCompilerOutput = []; |
|
235 | 235 | |
236 | - // list |
|
237 | - $listModuleCompilerOutput = []; |
|
238 | - $listControllerCompilerOutput = []; |
|
239 | - $listTemplateCompilerOutput = []; |
|
240 | - //$listDetailCompilerOutput = []; |
|
241 | - //$listChooseColumnsCompilerOutput = []; |
|
242 | - |
|
243 | - // Compiled indexes |
|
244 | - $compiledIndexes = ''; |
|
236 | + // list |
|
237 | + $listModuleCompilerOutput = []; |
|
238 | + $listControllerCompilerOutput = []; |
|
239 | + $listTemplateCompilerOutput = []; |
|
240 | + //$listDetailCompilerOutput = []; |
|
241 | + //$listChooseColumnsCompilerOutput = []; |
|
242 | + |
|
243 | + // Compiled indexes |
|
244 | + $compiledIndexes = ''; |
|
245 | 245 | |
246 | - // Create index compiler |
|
247 | - $indexModuleCompiler = new IndexModuleCompiler($scaffolderConfig); |
|
246 | + // Create index compiler |
|
247 | + $indexModuleCompiler = new IndexModuleCompiler($scaffolderConfig); |
|
248 | 248 | |
249 | - $indexApiCompiler = new IndexApiCompiler($scaffolderConfig); |
|
249 | + $indexApiCompiler = new IndexApiCompiler($scaffolderConfig); |
|
250 | 250 | |
251 | - // Create drafts directory |
|
252 | - // pages |
|
253 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->pages), 0755, true); |
|
251 | + // Create drafts directory |
|
252 | + // pages |
|
253 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->pages), 0755, true); |
|
254 | 254 | |
255 | - $intKey = 1; |
|
256 | - // Iterate over models data |
|
257 | - foreach ($modelsData as $modelData) |
|
258 | - { |
|
255 | + $intKey = 1; |
|
256 | + // Iterate over models data |
|
257 | + foreach ($modelsData as $modelData) |
|
258 | + { |
|
259 | 259 | |
260 | - // Create Compilers |
|
261 | - $resourceCompiler = new ResourceCompiler($scaffolderConfig, $modelData); |
|
262 | - $moduleCompiler = new ModuleCompiler($scaffolderConfig, $modelData); |
|
263 | - // register |
|
264 | - $registerModuleCompiler = new RegisterModuleCompiler($scaffolderConfig, $modelData); |
|
265 | - $registerControllerCompiler = new RegisterControllerCompiler($scaffolderConfig, $modelData); |
|
266 | - $registerTemplateCompiler = new RegisterTemplateCompiler($scaffolderConfig, $modelData); |
|
267 | - // translate |
|
268 | - $translateCompiler = new TranslateCompiler($scaffolderConfig, $modelData); |
|
269 | - // list |
|
270 | - $listModuleCompiler = new ListModuleCompiler($scaffolderConfig, $modelData); |
|
271 | - $listControllerCompiler = new ListControllerCompiler($scaffolderConfig, $modelData); |
|
272 | - $listTemplateCompiler = new ListTemplateCompiler($scaffolderConfig, $modelData); |
|
273 | - //$listDetailCompiler = new ListDetailCompiler($scaffolderConfig, $modelData); |
|
274 | - //$listChooseColumnsCompiler = new ListChooseColumnsCompiler($scaffolderConfig, $modelData); |
|
260 | + // Create Compilers |
|
261 | + $resourceCompiler = new ResourceCompiler($scaffolderConfig, $modelData); |
|
262 | + $moduleCompiler = new ModuleCompiler($scaffolderConfig, $modelData); |
|
263 | + // register |
|
264 | + $registerModuleCompiler = new RegisterModuleCompiler($scaffolderConfig, $modelData); |
|
265 | + $registerControllerCompiler = new RegisterControllerCompiler($scaffolderConfig, $modelData); |
|
266 | + $registerTemplateCompiler = new RegisterTemplateCompiler($scaffolderConfig, $modelData); |
|
267 | + // translate |
|
268 | + $translateCompiler = new TranslateCompiler($scaffolderConfig, $modelData); |
|
269 | + // list |
|
270 | + $listModuleCompiler = new ListModuleCompiler($scaffolderConfig, $modelData); |
|
271 | + $listControllerCompiler = new ListControllerCompiler($scaffolderConfig, $modelData); |
|
272 | + $listTemplateCompiler = new ListTemplateCompiler($scaffolderConfig, $modelData); |
|
273 | + //$listDetailCompiler = new ListDetailCompiler($scaffolderConfig, $modelData); |
|
274 | + //$listChooseColumnsCompiler = new ListChooseColumnsCompiler($scaffolderConfig, $modelData); |
|
275 | 275 | |
276 | - // Compile stubs |
|
277 | - array_push($resourceCompilerOutput, $resourceCompiler->compile()); |
|
278 | - array_push($moduleCompilerOutput, $moduleCompiler->compile()); |
|
279 | - array_push($translateCompilerOutput, $translateCompiler->compile()); |
|
280 | - // register |
|
281 | - array_push($registerModuleCompilerOutput, $registerModuleCompiler->compile()); |
|
282 | - array_push($registerControllerCompilerOutput, $registerControllerCompiler->compile()); |
|
283 | - array_push($registerTemplateCompilerOutput, $registerTemplateCompiler->compile()); |
|
284 | - // list |
|
285 | - array_push($listModuleCompilerOutput, $listModuleCompiler->compile()); |
|
286 | - array_push($listControllerCompilerOutput, $listControllerCompiler->compile()); |
|
287 | - array_push($listTemplateCompilerOutput, $listTemplateCompiler->compile()); |
|
288 | - //array_push($listDetailCompilerOutput, $listDetailCompiler->compile()); |
|
289 | - //array_push($listChooseColumnsCompilerOutput, $listChooseColumnsCompiler->compile()); |
|
290 | - |
|
291 | - $compiledIndexes .= $indexModuleCompiler->replaceResource($modelData); |
|
292 | - if ($intKey < count($modelsData)) |
|
293 | - $compiledIndexes .= ","; |
|
294 | - |
|
295 | - $intKey++; |
|
296 | - // Advance progress |
|
297 | - $this->output->progressAdvance(); |
|
298 | - } |
|
299 | - |
|
300 | - // Store compiled indexes |
|
301 | - $indexModuleCompiler->compileGroup($compiledIndexes); |
|
276 | + // Compile stubs |
|
277 | + array_push($resourceCompilerOutput, $resourceCompiler->compile()); |
|
278 | + array_push($moduleCompilerOutput, $moduleCompiler->compile()); |
|
279 | + array_push($translateCompilerOutput, $translateCompiler->compile()); |
|
280 | + // register |
|
281 | + array_push($registerModuleCompilerOutput, $registerModuleCompiler->compile()); |
|
282 | + array_push($registerControllerCompilerOutput, $registerControllerCompiler->compile()); |
|
283 | + array_push($registerTemplateCompilerOutput, $registerTemplateCompiler->compile()); |
|
284 | + // list |
|
285 | + array_push($listModuleCompilerOutput, $listModuleCompiler->compile()); |
|
286 | + array_push($listControllerCompilerOutput, $listControllerCompiler->compile()); |
|
287 | + array_push($listTemplateCompilerOutput, $listTemplateCompiler->compile()); |
|
288 | + //array_push($listDetailCompilerOutput, $listDetailCompiler->compile()); |
|
289 | + //array_push($listChooseColumnsCompilerOutput, $listChooseColumnsCompiler->compile()); |
|
290 | + |
|
291 | + $compiledIndexes .= $indexModuleCompiler->replaceResource($modelData); |
|
292 | + if ($intKey < count($modelsData)) |
|
293 | + $compiledIndexes .= ","; |
|
294 | + |
|
295 | + $intKey++; |
|
296 | + // Advance progress |
|
297 | + $this->output->progressAdvance(); |
|
298 | + } |
|
299 | + |
|
300 | + // Store compiled indexes |
|
301 | + $indexModuleCompiler->compileGroup($compiledIndexes); |
|
302 | 302 | |
303 | - // store compiled api |
|
304 | - $fileApi = $indexApiCompiler->compile(); |
|
303 | + // store compiled api |
|
304 | + $fileApi = $indexApiCompiler->compile(); |
|
305 | 305 | |
306 | - // Advance progress |
|
307 | - $this->output->progressAdvance(); |
|
306 | + // Advance progress |
|
307 | + $this->output->progressAdvance(); |
|
308 | 308 | |
309 | - // Finish progress |
|
310 | - $this->output->progressFinish(); |
|
311 | - |
|
312 | - // Summary |
|
313 | - $this->comment('- Files created'); |
|
314 | - |
|
315 | - $this->comment('- - Index Api'); |
|
316 | - |
|
317 | - $this->info('- - - ' . $fileApi); |
|
318 | - |
|
319 | - $this->comment('- - Resources'); |
|
320 | - foreach ($resourceCompilerOutput as $file) |
|
321 | - { |
|
322 | - $this->info('- - - ' . $file); |
|
323 | - } |
|
324 | - |
|
325 | - $this->comment('- - Modules'); |
|
326 | - foreach ($moduleCompilerOutput as $file) |
|
327 | - { |
|
328 | - $this->info('- - - ' . $file); |
|
329 | - } |
|
330 | - |
|
331 | - $this->comment('- - Translate'); |
|
332 | - foreach ($translateCompilerOutput as $file) |
|
333 | - { |
|
334 | - $this->info('- - - ' . $file); |
|
335 | - } |
|
336 | - |
|
337 | - $this->comment('- - Register'); |
|
338 | - |
|
339 | - $this->comment('- - - Modules'); |
|
340 | - foreach ($registerModuleCompilerOutput as $file) |
|
341 | - { |
|
342 | - $this->info('- - - - ' . $file); |
|
343 | - } |
|
344 | - |
|
345 | - $this->comment('- - - Controllers'); |
|
346 | - foreach ($registerControllerCompilerOutput as $file) |
|
347 | - { |
|
348 | - $this->info('- - - - ' . $file); |
|
349 | - } |
|
350 | - |
|
351 | - $this->comment('- - - Templates'); |
|
352 | - foreach ($registerTemplateCompilerOutput as $file) |
|
353 | - { |
|
354 | - $this->info('- - - - ' . $file); |
|
355 | - } |
|
356 | - |
|
357 | - $this->comment('- - List'); |
|
358 | - |
|
359 | - $this->comment('- - - Modules'); |
|
360 | - foreach ($listModuleCompilerOutput as $file) |
|
361 | - { |
|
362 | - $this->info('- - - - ' . $file); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - $this->comment('- - - Controllers'); |
|
367 | - foreach ($listControllerCompilerOutput as $file) |
|
368 | - { |
|
369 | - $this->info('- - - - ' . $file); |
|
370 | - } |
|
371 | - |
|
372 | - $this->comment('- - - Templates'); |
|
373 | - foreach ($listTemplateCompilerOutput as $file) |
|
374 | - { |
|
375 | - $this->info('- - - - ' . $file); |
|
376 | - } |
|
377 | - /* |
|
309 | + // Finish progress |
|
310 | + $this->output->progressFinish(); |
|
311 | + |
|
312 | + // Summary |
|
313 | + $this->comment('- Files created'); |
|
314 | + |
|
315 | + $this->comment('- - Index Api'); |
|
316 | + |
|
317 | + $this->info('- - - ' . $fileApi); |
|
318 | + |
|
319 | + $this->comment('- - Resources'); |
|
320 | + foreach ($resourceCompilerOutput as $file) |
|
321 | + { |
|
322 | + $this->info('- - - ' . $file); |
|
323 | + } |
|
324 | + |
|
325 | + $this->comment('- - Modules'); |
|
326 | + foreach ($moduleCompilerOutput as $file) |
|
327 | + { |
|
328 | + $this->info('- - - ' . $file); |
|
329 | + } |
|
330 | + |
|
331 | + $this->comment('- - Translate'); |
|
332 | + foreach ($translateCompilerOutput as $file) |
|
333 | + { |
|
334 | + $this->info('- - - ' . $file); |
|
335 | + } |
|
336 | + |
|
337 | + $this->comment('- - Register'); |
|
338 | + |
|
339 | + $this->comment('- - - Modules'); |
|
340 | + foreach ($registerModuleCompilerOutput as $file) |
|
341 | + { |
|
342 | + $this->info('- - - - ' . $file); |
|
343 | + } |
|
344 | + |
|
345 | + $this->comment('- - - Controllers'); |
|
346 | + foreach ($registerControllerCompilerOutput as $file) |
|
347 | + { |
|
348 | + $this->info('- - - - ' . $file); |
|
349 | + } |
|
350 | + |
|
351 | + $this->comment('- - - Templates'); |
|
352 | + foreach ($registerTemplateCompilerOutput as $file) |
|
353 | + { |
|
354 | + $this->info('- - - - ' . $file); |
|
355 | + } |
|
356 | + |
|
357 | + $this->comment('- - List'); |
|
358 | + |
|
359 | + $this->comment('- - - Modules'); |
|
360 | + foreach ($listModuleCompilerOutput as $file) |
|
361 | + { |
|
362 | + $this->info('- - - - ' . $file); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + $this->comment('- - - Controllers'); |
|
367 | + foreach ($listControllerCompilerOutput as $file) |
|
368 | + { |
|
369 | + $this->info('- - - - ' . $file); |
|
370 | + } |
|
371 | + |
|
372 | + $this->comment('- - - Templates'); |
|
373 | + foreach ($listTemplateCompilerOutput as $file) |
|
374 | + { |
|
375 | + $this->info('- - - - ' . $file); |
|
376 | + } |
|
377 | + /* |
|
378 | 378 | $this->comment('- - - Detail Dialog'); |
379 | 379 | foreach ($listDetailCompilerOutput as $file) |
380 | 380 | { |
@@ -388,296 +388,296 @@ discard block |
||
388 | 388 | } |
389 | 389 | */ |
390 | 390 | |
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Generation command for Blade. |
|
395 | - * Generates Blade templates |
|
396 | - * @return void |
|
397 | - */ |
|
398 | - private function handleBlade(){ |
|
399 | - // Get all the models |
|
400 | - $modelsData = $this->getAllModelsData(); |
|
401 | - |
|
402 | - // Start progress bar |
|
403 | - $this->output->progressStart(count($modelsData)); |
|
404 | - |
|
405 | - // Get app config |
|
406 | - $scaffolderConfig = $this->getScaffolderConfig(); |
|
407 | - |
|
408 | - // Compilers |
|
409 | - $indexViewCompiler = new IndexViewCompiler(); |
|
410 | - $createViewCompiler = new CreateViewCompiler(); |
|
411 | - $editViewCompiler = new EditViewCompiler(); |
|
412 | - $pageLayoutViewCompiler = new PageLayoutCompiler(); |
|
413 | - |
|
414 | - // Compiler output |
|
415 | - $viewCompilerOutput = []; |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Generation command for Blade. |
|
395 | + * Generates Blade templates |
|
396 | + * @return void |
|
397 | + */ |
|
398 | + private function handleBlade(){ |
|
399 | + // Get all the models |
|
400 | + $modelsData = $this->getAllModelsData(); |
|
401 | + |
|
402 | + // Start progress bar |
|
403 | + $this->output->progressStart(count($modelsData)); |
|
404 | + |
|
405 | + // Get app config |
|
406 | + $scaffolderConfig = $this->getScaffolderConfig(); |
|
407 | + |
|
408 | + // Compilers |
|
409 | + $indexViewCompiler = new IndexViewCompiler(); |
|
410 | + $createViewCompiler = new CreateViewCompiler(); |
|
411 | + $editViewCompiler = new EditViewCompiler(); |
|
412 | + $pageLayoutViewCompiler = new PageLayoutCompiler(); |
|
413 | + |
|
414 | + // Compiler output |
|
415 | + $viewCompilerOutput = []; |
|
416 | 416 | |
417 | - // Sidenav links |
|
418 | - $sidenavLinks = []; |
|
417 | + // Sidenav links |
|
418 | + $sidenavLinks = []; |
|
419 | 419 | |
420 | - // Compiled routes |
|
421 | - $compiledRoutes = ''; |
|
420 | + // Compiled routes |
|
421 | + $compiledRoutes = ''; |
|
422 | 422 | |
423 | - // Get stubs |
|
424 | - $indexViewStub = File::get($this->themeViews->getIndexPath()); |
|
425 | - $createViewStub = File::get($this->themeViews->getCreatePath()); |
|
426 | - $editViewStub = File::get($this->themeViews->getEditPath()); |
|
423 | + // Get stubs |
|
424 | + $indexViewStub = File::get($this->themeViews->getIndexPath()); |
|
425 | + $createViewStub = File::get($this->themeViews->getCreatePath()); |
|
426 | + $editViewStub = File::get($this->themeViews->getEditPath()); |
|
427 | 427 | |
428 | - // views |
|
429 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->views), 0755, true); |
|
430 | - // layouts |
|
431 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->layouts), 0755, true); |
|
432 | - // assets |
|
433 | - Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->assets), 0755, true); |
|
428 | + // views |
|
429 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->views), 0755, true); |
|
430 | + // layouts |
|
431 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->layouts), 0755, true); |
|
432 | + // assets |
|
433 | + Directory::createIfNotExists(PathParser::parse($scaffolderConfig->generator->paths->assets), 0755, true); |
|
434 | 434 | |
435 | 435 | |
436 | - // Iterate over model files |
|
437 | - foreach ($modelsData as $modelData) |
|
438 | - { |
|
439 | - // Get model name |
|
440 | - $modelName = $modelData->modelName; |
|
441 | - |
|
442 | - // Create views directory |
|
443 | - Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName))); |
|
444 | - |
|
445 | - //set hash |
|
446 | - $modelHash = $modelData->modelHash; |
|
447 | - |
|
448 | - |
|
449 | - // Compile stubs |
|
450 | - array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
451 | - array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
452 | - array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
453 | - // Add entity link |
|
454 | - array_push($sidenavLinks, $modelName); |
|
455 | - |
|
456 | - // Advance progress |
|
457 | - $this->output->progressAdvance(); |
|
458 | - } |
|
459 | - |
|
460 | - // Create layouts directory |
|
461 | - Directory::createIfNotExists(base_path('resources/views/layouts'), 0755, true); |
|
462 | - |
|
463 | - // Store compiled page layout |
|
464 | - array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks])); |
|
465 | - |
|
466 | - // Store create layout |
|
467 | - $createLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/create.blade.php' ; |
|
468 | - File::copy($this->themeLayouts->getCreatePath(), $createLayout); |
|
469 | - array_push($viewCompilerOutput, $createLayout); |
|
470 | - |
|
471 | - // Store edit layout |
|
472 | - $editLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/edit.blade.php' ; |
|
473 | - File::copy($this->themeLayouts->getCreatePath(), $editLayout); |
|
474 | - array_push($viewCompilerOutput, $editLayout); |
|
475 | - |
|
476 | - // Store dashboard |
|
477 | - $dashboardLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/dashboard.blade.php' ; |
|
478 | - File::copy($this->themeLayouts->getCreatePath(), $dashboardLayout); |
|
479 | - array_push($viewCompilerOutput, $dashboardLayout); |
|
480 | - |
|
481 | - // Finish progress |
|
482 | - $this->output->progressFinish(); |
|
483 | - |
|
484 | - // Summary |
|
485 | - $this->comment('- Files created'); |
|
486 | - |
|
487 | - $this->comment('- - Views'); |
|
488 | - foreach ($viewCompilerOutput as $viewFile) |
|
489 | - { |
|
490 | - $this->info('- - - ' . $viewFile); |
|
491 | - } |
|
492 | - |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * Generation command for laravel. |
|
497 | - * Generates API Code |
|
498 | - * Generates Blade templates |
|
499 | - * @return void |
|
500 | - */ |
|
501 | - private function handleLaravel(){ |
|
502 | - // generate API |
|
503 | - $this->handleApi(); |
|
504 | - |
|
505 | - // generate BLADE |
|
506 | - $this->handleApi(); |
|
507 | - |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Get the app.json configuration and parse to an object |
|
512 | - * |
|
513 | - * @return void |
|
514 | - */ |
|
515 | - private function getScaffolderConfig(){ |
|
516 | - // Get app config |
|
517 | - $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
|
518 | - |
|
519 | - $scaffolderConfig->generator = $scaffolderConfig->generators->{$this->argument('app')}; |
|
520 | - |
|
521 | - return $scaffolderConfig ; |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * Get all model files and ordenates by |
|
526 | - * |
|
527 | - * @return object |
|
528 | - */ |
|
529 | - private function getAllModelsData(){ |
|
530 | - |
|
531 | - $modelFiles = File::allFiles(base_path('scaffolder-config/models/')); |
|
532 | - |
|
533 | - $modelsData = []; |
|
534 | - $orderedModelsData = []; |
|
535 | - |
|
536 | - // set indexes |
|
537 | - //$firstKey = |
|
538 | - foreach ($modelFiles as $modelFile) |
|
539 | - { |
|
436 | + // Iterate over model files |
|
437 | + foreach ($modelsData as $modelData) |
|
438 | + { |
|
439 | + // Get model name |
|
440 | + $modelName = $modelData->modelName; |
|
441 | + |
|
442 | + // Create views directory |
|
443 | + Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName))); |
|
540 | 444 | |
541 | - // Get model data |
|
542 | - $modelData = Json::decodeFile($modelFile->getRealPath()); |
|
445 | + //set hash |
|
446 | + $modelHash = $modelData->modelHash; |
|
543 | 447 | |
544 | 448 | |
545 | - // Get model name |
|
546 | - $modelName = CamelCase::convertToCamelCase(($modelFile->getBasename('.' . $modelFile->getExtension()))); |
|
449 | + // Compile stubs |
|
450 | + array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
451 | + array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
452 | + array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash)); |
|
453 | + // Add entity link |
|
454 | + array_push($sidenavLinks, $modelName); |
|
547 | 455 | |
548 | - // Get model hash |
|
549 | - $modelHash = md5_file($modelFile->getRealPath()); |
|
456 | + // Advance progress |
|
457 | + $this->output->progressAdvance(); |
|
458 | + } |
|
550 | 459 | |
551 | - // Set model name |
|
552 | - $modelData->modelName = $modelName ; |
|
460 | + // Create layouts directory |
|
461 | + Directory::createIfNotExists(base_path('resources/views/layouts'), 0755, true); |
|
553 | 462 | |
554 | - // Set model name |
|
555 | - $modelData->modelHash = $modelHash ; |
|
463 | + // Store compiled page layout |
|
464 | + array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks])); |
|
556 | 465 | |
557 | - // get primary field or create |
|
558 | - $primaryField = $this->getPrimaryKeyField($modelData); |
|
466 | + // Store create layout |
|
467 | + $createLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/create.blade.php' ; |
|
468 | + File::copy($this->themeLayouts->getCreatePath(), $createLayout); |
|
469 | + array_push($viewCompilerOutput, $createLayout); |
|
559 | 470 | |
560 | - // put primary key at first position |
|
561 | - if(isset($primaryField->declared) && !$primaryField->declared){ |
|
562 | - $modelData->fields = array_pad($modelData->fields, -(count($modelData->fields)+1), $primaryField); |
|
563 | - } |
|
564 | - |
|
565 | - // set timestamps |
|
566 | - if($modelData->timeStamps){ |
|
567 | - $createdAtField = new stdClass; |
|
568 | - $createdAtField->name = "created_at" ; |
|
569 | - $createdAtField->index = "none" ; |
|
570 | - $createdAtField->declared = false ; |
|
571 | - $createdAtField->type = new stdClass ; |
|
572 | - $createdAtField->type->ui = 'timestamp' ; |
|
573 | - $createdAtField->type->db = 'datetime' ; |
|
574 | - $createdAtField->foreignKey = []; |
|
575 | - $createdAtField->validations = "required" ; |
|
576 | - $updatedAtField = clone($createdAtField); |
|
577 | - $updatedAtField->name = "updated_at" ; |
|
578 | - |
|
579 | - array_push($modelData->fields, $createdAtField); |
|
580 | - array_push($modelData->fields, $updatedAtField); |
|
581 | - } |
|
582 | - |
|
583 | - $modelsData[$modelData->tableName] = $modelData ; |
|
584 | - |
|
585 | - // put all migrations pre-requisites in top of generation hieraquical |
|
586 | - if(count($modelData->migrationPreRequisites) == 0){ |
|
587 | - $modelsData = Arrays::moveElement($modelsData, $modelData->tableName, 0); |
|
588 | - } |
|
589 | - |
|
590 | - } |
|
591 | - |
|
592 | - // let put all pre-requisites in order |
|
593 | - $actualTablePosition = 0 ; |
|
594 | - foreach ($modelsData as $key => $modelData) |
|
595 | - { |
|
596 | - // set migration order |
|
597 | - $modelData->migrationOrder = isset($modelData->migrationOrder) ? $modelData->migrationOrder : $actualTablePosition ; |
|
598 | - |
|
599 | - $positions = array_keys($modelsData); |
|
600 | - |
|
601 | - foreach($modelData->migrationPreRequisites as $preRequiste){ |
|
602 | - $preRequisitePosition = array_search($preRequiste, $positions); |
|
603 | - // change positions |
|
604 | - if( $preRequisitePosition > $actualTablePosition){ |
|
605 | - $modelData->migrationOrder = $preRequisitePosition ; |
|
606 | - $modelsData[$preRequiste]->migrationOrder = $actualTablePosition ; |
|
607 | - $modelsData = Arrays::moveElement($modelsData, $preRequiste, $actualTablePosition); |
|
471 | + // Store edit layout |
|
472 | + $editLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/edit.blade.php' ; |
|
473 | + File::copy($this->themeLayouts->getCreatePath(), $editLayout); |
|
474 | + array_push($viewCompilerOutput, $editLayout); |
|
475 | + |
|
476 | + // Store dashboard |
|
477 | + $dashboardLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/dashboard.blade.php' ; |
|
478 | + File::copy($this->themeLayouts->getCreatePath(), $dashboardLayout); |
|
479 | + array_push($viewCompilerOutput, $dashboardLayout); |
|
480 | + |
|
481 | + // Finish progress |
|
482 | + $this->output->progressFinish(); |
|
483 | + |
|
484 | + // Summary |
|
485 | + $this->comment('- Files created'); |
|
486 | + |
|
487 | + $this->comment('- - Views'); |
|
488 | + foreach ($viewCompilerOutput as $viewFile) |
|
489 | + { |
|
490 | + $this->info('- - - ' . $viewFile); |
|
491 | + } |
|
492 | + |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * Generation command for laravel. |
|
497 | + * Generates API Code |
|
498 | + * Generates Blade templates |
|
499 | + * @return void |
|
500 | + */ |
|
501 | + private function handleLaravel(){ |
|
502 | + // generate API |
|
503 | + $this->handleApi(); |
|
504 | + |
|
505 | + // generate BLADE |
|
506 | + $this->handleApi(); |
|
507 | + |
|
508 | + } |
|
509 | + |
|
510 | + /** |
|
511 | + * Get the app.json configuration and parse to an object |
|
512 | + * |
|
513 | + * @return void |
|
514 | + */ |
|
515 | + private function getScaffolderConfig(){ |
|
516 | + // Get app config |
|
517 | + $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
|
518 | + |
|
519 | + $scaffolderConfig->generator = $scaffolderConfig->generators->{$this->argument('app')}; |
|
520 | + |
|
521 | + return $scaffolderConfig ; |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * Get all model files and ordenates by |
|
526 | + * |
|
527 | + * @return object |
|
528 | + */ |
|
529 | + private function getAllModelsData(){ |
|
530 | + |
|
531 | + $modelFiles = File::allFiles(base_path('scaffolder-config/models/')); |
|
532 | + |
|
533 | + $modelsData = []; |
|
534 | + $orderedModelsData = []; |
|
535 | + |
|
536 | + // set indexes |
|
537 | + //$firstKey = |
|
538 | + foreach ($modelFiles as $modelFile) |
|
539 | + { |
|
540 | + |
|
541 | + // Get model data |
|
542 | + $modelData = Json::decodeFile($modelFile->getRealPath()); |
|
543 | + |
|
544 | + |
|
545 | + // Get model name |
|
546 | + $modelName = CamelCase::convertToCamelCase(($modelFile->getBasename('.' . $modelFile->getExtension()))); |
|
547 | + |
|
548 | + // Get model hash |
|
549 | + $modelHash = md5_file($modelFile->getRealPath()); |
|
550 | + |
|
551 | + // Set model name |
|
552 | + $modelData->modelName = $modelName ; |
|
553 | + |
|
554 | + // Set model name |
|
555 | + $modelData->modelHash = $modelHash ; |
|
556 | + |
|
557 | + // get primary field or create |
|
558 | + $primaryField = $this->getPrimaryKeyField($modelData); |
|
559 | + |
|
560 | + // put primary key at first position |
|
561 | + if(isset($primaryField->declared) && !$primaryField->declared){ |
|
562 | + $modelData->fields = array_pad($modelData->fields, -(count($modelData->fields)+1), $primaryField); |
|
563 | + } |
|
564 | + |
|
565 | + // set timestamps |
|
566 | + if($modelData->timeStamps){ |
|
567 | + $createdAtField = new stdClass; |
|
568 | + $createdAtField->name = "created_at" ; |
|
569 | + $createdAtField->index = "none" ; |
|
570 | + $createdAtField->declared = false ; |
|
571 | + $createdAtField->type = new stdClass ; |
|
572 | + $createdAtField->type->ui = 'timestamp' ; |
|
573 | + $createdAtField->type->db = 'datetime' ; |
|
574 | + $createdAtField->foreignKey = []; |
|
575 | + $createdAtField->validations = "required" ; |
|
576 | + $updatedAtField = clone($createdAtField); |
|
577 | + $updatedAtField->name = "updated_at" ; |
|
578 | + |
|
579 | + array_push($modelData->fields, $createdAtField); |
|
580 | + array_push($modelData->fields, $updatedAtField); |
|
581 | + } |
|
582 | + |
|
583 | + $modelsData[$modelData->tableName] = $modelData ; |
|
584 | + |
|
585 | + // put all migrations pre-requisites in top of generation hieraquical |
|
586 | + if(count($modelData->migrationPreRequisites) == 0){ |
|
587 | + $modelsData = Arrays::moveElement($modelsData, $modelData->tableName, 0); |
|
588 | + } |
|
589 | + |
|
590 | + } |
|
591 | + |
|
592 | + // let put all pre-requisites in order |
|
593 | + $actualTablePosition = 0 ; |
|
594 | + foreach ($modelsData as $key => $modelData) |
|
595 | + { |
|
596 | + // set migration order |
|
597 | + $modelData->migrationOrder = isset($modelData->migrationOrder) ? $modelData->migrationOrder : $actualTablePosition ; |
|
598 | + |
|
599 | + $positions = array_keys($modelsData); |
|
600 | + |
|
601 | + foreach($modelData->migrationPreRequisites as $preRequiste){ |
|
602 | + $preRequisitePosition = array_search($preRequiste, $positions); |
|
603 | + // change positions |
|
604 | + if( $preRequisitePosition > $actualTablePosition){ |
|
605 | + $modelData->migrationOrder = $preRequisitePosition ; |
|
606 | + $modelsData[$preRequiste]->migrationOrder = $actualTablePosition ; |
|
607 | + $modelsData = Arrays::moveElement($modelsData, $preRequiste, $actualTablePosition); |
|
608 | 608 | |
609 | - } |
|
610 | - } |
|
609 | + } |
|
610 | + } |
|
611 | 611 | |
612 | 612 | |
613 | - // search for other fields relationships |
|
614 | - foreach($modelData->fields as $field){ |
|
613 | + // search for other fields relationships |
|
614 | + foreach($modelData->fields as $field){ |
|
615 | 615 | |
616 | 616 | |
617 | - if(isset($field->foreignKey->relationship)){ |
|
618 | - switch ($field->foreignKey->relationship) { |
|
619 | - case 'belongsTo': |
|
620 | - // hasOne or hasMay are the inverse relationship for belongsTo |
|
621 | - $relationship = new stdClass ; |
|
622 | - $relationship->type = $field->foreignKey->reverse ; |
|
623 | - $relationship->foreignKey = $field->name ; |
|
624 | - $relationship->localKey = $field->foreignKey->field ; |
|
625 | - $relationship->modelName = $modelData->modelName ; |
|
626 | - array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
|
627 | - break; |
|
628 | - case 'belongsToMany': |
|
629 | - // belongsToMany is the inverse relationship for belongsTo |
|
630 | - $relationship = new stdClass ; |
|
631 | - $relationship->type = $field->foreignKey->reverse ; |
|
632 | - $relationship->foreignKey = $field->name ; |
|
633 | - $relationship->relatedTable = isset($field->relatedTable) ? $field->relatedTable : ''; |
|
634 | - $relationship->relatedField = isset($field->relatedField) ? $field->relatedField : ''; |
|
635 | - $relationship->ui = $field->type->ui; |
|
636 | - $relationship->localKey = $field->foreignKey->field ; |
|
637 | - $relationship->modelName = $modelData->modelName ; |
|
638 | - $relationship->tableName = $modelData->tableName ; |
|
639 | - array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
|
640 | - break; |
|
641 | - default: |
|
642 | - # code... |
|
643 | - break; |
|
644 | - } |
|
617 | + if(isset($field->foreignKey->relationship)){ |
|
618 | + switch ($field->foreignKey->relationship) { |
|
619 | + case 'belongsTo': |
|
620 | + // hasOne or hasMay are the inverse relationship for belongsTo |
|
621 | + $relationship = new stdClass ; |
|
622 | + $relationship->type = $field->foreignKey->reverse ; |
|
623 | + $relationship->foreignKey = $field->name ; |
|
624 | + $relationship->localKey = $field->foreignKey->field ; |
|
625 | + $relationship->modelName = $modelData->modelName ; |
|
626 | + array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
|
627 | + break; |
|
628 | + case 'belongsToMany': |
|
629 | + // belongsToMany is the inverse relationship for belongsTo |
|
630 | + $relationship = new stdClass ; |
|
631 | + $relationship->type = $field->foreignKey->reverse ; |
|
632 | + $relationship->foreignKey = $field->name ; |
|
633 | + $relationship->relatedTable = isset($field->relatedTable) ? $field->relatedTable : ''; |
|
634 | + $relationship->relatedField = isset($field->relatedField) ? $field->relatedField : ''; |
|
635 | + $relationship->ui = $field->type->ui; |
|
636 | + $relationship->localKey = $field->foreignKey->field ; |
|
637 | + $relationship->modelName = $modelData->modelName ; |
|
638 | + $relationship->tableName = $modelData->tableName ; |
|
639 | + array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
|
640 | + break; |
|
641 | + default: |
|
642 | + # code... |
|
643 | + break; |
|
644 | + } |
|
645 | 645 | |
646 | - } |
|
646 | + } |
|
647 | 647 | |
648 | - } |
|
648 | + } |
|
649 | 649 | |
650 | 650 | |
651 | - $actualTablePosition++ ; |
|
652 | - } |
|
651 | + $actualTablePosition++ ; |
|
652 | + } |
|
653 | 653 | |
654 | - // $this->info(print_r($modelsData, 1)); |
|
654 | + // $this->info(print_r($modelsData, 1)); |
|
655 | 655 | |
656 | - return $modelsData ; |
|
656 | + return $modelsData ; |
|
657 | 657 | |
658 | - } |
|
659 | - |
|
660 | - protected function getPrimaryKeyField($modelData){ |
|
661 | - $primaryKey = new stdClass; |
|
662 | - $primaryKey->name = "id" ; |
|
663 | - $primaryKey->index = "primary" ; |
|
664 | - $primaryKey->declared = false ; |
|
665 | - $primaryKey->type = new stdClass ; |
|
666 | - $primaryKey->type->ui = 'label' ; |
|
667 | - $primaryKey->type->db = 'integer' ; |
|
668 | - $primaryKey->foreignKey = []; |
|
669 | - $primaryKey->validations = "required" ; |
|
670 | - |
|
671 | - foreach ($modelData->fields as $field) |
|
672 | - { |
|
673 | - if ($field->index == 'primary') |
|
674 | - { |
|
675 | - $primaryKey = $field ; |
|
676 | - break; |
|
677 | - } |
|
678 | - } |
|
679 | - |
|
680 | - return $primaryKey ; |
|
681 | - } |
|
658 | + } |
|
659 | + |
|
660 | + protected function getPrimaryKeyField($modelData){ |
|
661 | + $primaryKey = new stdClass; |
|
662 | + $primaryKey->name = "id" ; |
|
663 | + $primaryKey->index = "primary" ; |
|
664 | + $primaryKey->declared = false ; |
|
665 | + $primaryKey->type = new stdClass ; |
|
666 | + $primaryKey->type->ui = 'label' ; |
|
667 | + $primaryKey->type->db = 'integer' ; |
|
668 | + $primaryKey->foreignKey = []; |
|
669 | + $primaryKey->validations = "required" ; |
|
670 | + |
|
671 | + foreach ($modelData->fields as $field) |
|
672 | + { |
|
673 | + if ($field->index == 'primary') |
|
674 | + { |
|
675 | + $primaryKey = $field ; |
|
676 | + break; |
|
677 | + } |
|
678 | + } |
|
679 | + |
|
680 | + return $primaryKey ; |
|
681 | + } |
|
682 | 682 | |
683 | 683 | } |
684 | 684 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | use Scaffolder\Themes\IScaffolderThemeViews; |
44 | 44 | use Scaffolder\Compilers\Support\PathParser; |
45 | 45 | |
46 | -use stdClass ; |
|
46 | +use stdClass; |
|
47 | 47 | |
48 | 48 | class GeneratorCommand extends Command |
49 | 49 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | parent::__construct(); |
59 | 59 | |
60 | - $this->stubsDirectory = __DIR__ . '/../../../stubs/'; |
|
60 | + $this->stubsDirectory = __DIR__.'/../../../stubs/'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function handle() |
68 | 68 | { |
69 | 69 | // check if is to clear cache |
70 | - if($this->option('clear-all')){ |
|
70 | + if ($this->option('clear-all')) { |
|
71 | 71 | $this->call('scaffolder:clear'); |
72 | 72 | } |
73 | 73 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * API Generation command for API files. |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - private function handleApi(){ |
|
114 | + private function handleApi() { |
|
115 | 115 | // Get all the models |
116 | 116 | $modelsData = $this->getAllModelsData(); |
117 | 117 | |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | $this->comment('- - Controllers'); |
195 | 195 | foreach ($controllerCompilerOutput as $controllerFile) |
196 | 196 | { |
197 | - $this->info('- - - ' . $controllerFile); |
|
197 | + $this->info('- - - '.$controllerFile); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $this->comment('- - Migrations'); |
201 | 201 | foreach ($migrationCompilerOutput as $migrationFile) |
202 | 202 | { |
203 | - $this->info('- - - ' . $migrationFile); |
|
203 | + $this->info('- - - '.$migrationFile); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->comment('- - Models'); |
207 | 207 | foreach ($modelCompilerOutput as $modelFile) |
208 | 208 | { |
209 | - $this->info('- - - ' . $modelFile); |
|
209 | + $this->info('- - - '.$modelFile); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * Code Generation command for AngularJs Material design files. |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - private function handleAngularJs(){ |
|
217 | + private function handleAngularJs() { |
|
218 | 218 | // Get all the models |
219 | 219 | $modelsData = $this->getAllModelsData(); |
220 | 220 | |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | |
315 | 315 | $this->comment('- - Index Api'); |
316 | 316 | |
317 | - $this->info('- - - ' . $fileApi); |
|
317 | + $this->info('- - - '.$fileApi); |
|
318 | 318 | |
319 | 319 | $this->comment('- - Resources'); |
320 | 320 | foreach ($resourceCompilerOutput as $file) |
321 | 321 | { |
322 | - $this->info('- - - ' . $file); |
|
322 | + $this->info('- - - '.$file); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | $this->comment('- - Modules'); |
326 | 326 | foreach ($moduleCompilerOutput as $file) |
327 | 327 | { |
328 | - $this->info('- - - ' . $file); |
|
328 | + $this->info('- - - '.$file); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | $this->comment('- - Translate'); |
332 | 332 | foreach ($translateCompilerOutput as $file) |
333 | 333 | { |
334 | - $this->info('- - - ' . $file); |
|
334 | + $this->info('- - - '.$file); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | $this->comment('- - Register'); |
@@ -339,19 +339,19 @@ discard block |
||
339 | 339 | $this->comment('- - - Modules'); |
340 | 340 | foreach ($registerModuleCompilerOutput as $file) |
341 | 341 | { |
342 | - $this->info('- - - - ' . $file); |
|
342 | + $this->info('- - - - '.$file); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $this->comment('- - - Controllers'); |
346 | 346 | foreach ($registerControllerCompilerOutput as $file) |
347 | 347 | { |
348 | - $this->info('- - - - ' . $file); |
|
348 | + $this->info('- - - - '.$file); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | $this->comment('- - - Templates'); |
352 | 352 | foreach ($registerTemplateCompilerOutput as $file) |
353 | 353 | { |
354 | - $this->info('- - - - ' . $file); |
|
354 | + $this->info('- - - - '.$file); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | $this->comment('- - List'); |
@@ -359,20 +359,20 @@ discard block |
||
359 | 359 | $this->comment('- - - Modules'); |
360 | 360 | foreach ($listModuleCompilerOutput as $file) |
361 | 361 | { |
362 | - $this->info('- - - - ' . $file); |
|
362 | + $this->info('- - - - '.$file); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
366 | 366 | $this->comment('- - - Controllers'); |
367 | 367 | foreach ($listControllerCompilerOutput as $file) |
368 | 368 | { |
369 | - $this->info('- - - - ' . $file); |
|
369 | + $this->info('- - - - '.$file); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | $this->comment('- - - Templates'); |
373 | 373 | foreach ($listTemplateCompilerOutput as $file) |
374 | 374 | { |
375 | - $this->info('- - - - ' . $file); |
|
375 | + $this->info('- - - - '.$file); |
|
376 | 376 | } |
377 | 377 | /* |
378 | 378 | $this->comment('- - - Detail Dialog'); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * Generates Blade templates |
396 | 396 | * @return void |
397 | 397 | */ |
398 | - private function handleBlade(){ |
|
398 | + private function handleBlade() { |
|
399 | 399 | // Get all the models |
400 | 400 | $modelsData = $this->getAllModelsData(); |
401 | 401 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $modelName = $modelData->modelName; |
441 | 441 | |
442 | 442 | // Create views directory |
443 | - Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName))); |
|
443 | + Directory::createIfNotExists(base_path('resources/views/'.strtolower($modelName))); |
|
444 | 444 | |
445 | 445 | //set hash |
446 | 446 | $modelHash = $modelData->modelHash; |
@@ -464,17 +464,17 @@ discard block |
||
464 | 464 | array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks])); |
465 | 465 | |
466 | 466 | // Store create layout |
467 | - $createLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/create.blade.php' ; |
|
467 | + $createLayout = PathParser::parse($scaffolderConfig->generator->paths->views).'layouts/create.blade.php'; |
|
468 | 468 | File::copy($this->themeLayouts->getCreatePath(), $createLayout); |
469 | 469 | array_push($viewCompilerOutput, $createLayout); |
470 | 470 | |
471 | 471 | // Store edit layout |
472 | - $editLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/edit.blade.php' ; |
|
472 | + $editLayout = PathParser::parse($scaffolderConfig->generator->paths->views).'layouts/edit.blade.php'; |
|
473 | 473 | File::copy($this->themeLayouts->getCreatePath(), $editLayout); |
474 | 474 | array_push($viewCompilerOutput, $editLayout); |
475 | 475 | |
476 | 476 | // Store dashboard |
477 | - $dashboardLayout = PathParser::parse($scaffolderConfig->generator->paths->views). 'layouts/dashboard.blade.php' ; |
|
477 | + $dashboardLayout = PathParser::parse($scaffolderConfig->generator->paths->views).'layouts/dashboard.blade.php'; |
|
478 | 478 | File::copy($this->themeLayouts->getCreatePath(), $dashboardLayout); |
479 | 479 | array_push($viewCompilerOutput, $dashboardLayout); |
480 | 480 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $this->comment('- - Views'); |
488 | 488 | foreach ($viewCompilerOutput as $viewFile) |
489 | 489 | { |
490 | - $this->info('- - - ' . $viewFile); |
|
490 | + $this->info('- - - '.$viewFile); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * Generates Blade templates |
499 | 499 | * @return void |
500 | 500 | */ |
501 | - private function handleLaravel(){ |
|
501 | + private function handleLaravel() { |
|
502 | 502 | // generate API |
503 | 503 | $this->handleApi(); |
504 | 504 | |
@@ -512,13 +512,13 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return void |
514 | 514 | */ |
515 | - private function getScaffolderConfig(){ |
|
515 | + private function getScaffolderConfig() { |
|
516 | 516 | // Get app config |
517 | 517 | $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
518 | 518 | |
519 | 519 | $scaffolderConfig->generator = $scaffolderConfig->generators->{$this->argument('app')}; |
520 | 520 | |
521 | - return $scaffolderConfig ; |
|
521 | + return $scaffolderConfig; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return object |
528 | 528 | */ |
529 | - private function getAllModelsData(){ |
|
529 | + private function getAllModelsData() { |
|
530 | 530 | |
531 | 531 | $modelFiles = File::allFiles(base_path('scaffolder-config/models/')); |
532 | 532 | |
@@ -543,67 +543,67 @@ discard block |
||
543 | 543 | |
544 | 544 | |
545 | 545 | // Get model name |
546 | - $modelName = CamelCase::convertToCamelCase(($modelFile->getBasename('.' . $modelFile->getExtension()))); |
|
546 | + $modelName = CamelCase::convertToCamelCase(($modelFile->getBasename('.'.$modelFile->getExtension()))); |
|
547 | 547 | |
548 | 548 | // Get model hash |
549 | 549 | $modelHash = md5_file($modelFile->getRealPath()); |
550 | 550 | |
551 | 551 | // Set model name |
552 | - $modelData->modelName = $modelName ; |
|
552 | + $modelData->modelName = $modelName; |
|
553 | 553 | |
554 | 554 | // Set model name |
555 | - $modelData->modelHash = $modelHash ; |
|
555 | + $modelData->modelHash = $modelHash; |
|
556 | 556 | |
557 | 557 | // get primary field or create |
558 | 558 | $primaryField = $this->getPrimaryKeyField($modelData); |
559 | 559 | |
560 | 560 | // put primary key at first position |
561 | - if(isset($primaryField->declared) && !$primaryField->declared){ |
|
562 | - $modelData->fields = array_pad($modelData->fields, -(count($modelData->fields)+1), $primaryField); |
|
561 | + if (isset($primaryField->declared) && !$primaryField->declared) { |
|
562 | + $modelData->fields = array_pad($modelData->fields, -(count($modelData->fields) + 1), $primaryField); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | // set timestamps |
566 | - if($modelData->timeStamps){ |
|
566 | + if ($modelData->timeStamps) { |
|
567 | 567 | $createdAtField = new stdClass; |
568 | - $createdAtField->name = "created_at" ; |
|
569 | - $createdAtField->index = "none" ; |
|
570 | - $createdAtField->declared = false ; |
|
571 | - $createdAtField->type = new stdClass ; |
|
572 | - $createdAtField->type->ui = 'timestamp' ; |
|
573 | - $createdAtField->type->db = 'datetime' ; |
|
568 | + $createdAtField->name = "created_at"; |
|
569 | + $createdAtField->index = "none"; |
|
570 | + $createdAtField->declared = false; |
|
571 | + $createdAtField->type = new stdClass; |
|
572 | + $createdAtField->type->ui = 'timestamp'; |
|
573 | + $createdAtField->type->db = 'datetime'; |
|
574 | 574 | $createdAtField->foreignKey = []; |
575 | - $createdAtField->validations = "required" ; |
|
575 | + $createdAtField->validations = "required"; |
|
576 | 576 | $updatedAtField = clone($createdAtField); |
577 | - $updatedAtField->name = "updated_at" ; |
|
577 | + $updatedAtField->name = "updated_at"; |
|
578 | 578 | |
579 | 579 | array_push($modelData->fields, $createdAtField); |
580 | 580 | array_push($modelData->fields, $updatedAtField); |
581 | 581 | } |
582 | 582 | |
583 | - $modelsData[$modelData->tableName] = $modelData ; |
|
583 | + $modelsData[$modelData->tableName] = $modelData; |
|
584 | 584 | |
585 | 585 | // put all migrations pre-requisites in top of generation hieraquical |
586 | - if(count($modelData->migrationPreRequisites) == 0){ |
|
586 | + if (count($modelData->migrationPreRequisites) == 0) { |
|
587 | 587 | $modelsData = Arrays::moveElement($modelsData, $modelData->tableName, 0); |
588 | 588 | } |
589 | 589 | |
590 | 590 | } |
591 | 591 | |
592 | 592 | // let put all pre-requisites in order |
593 | - $actualTablePosition = 0 ; |
|
593 | + $actualTablePosition = 0; |
|
594 | 594 | foreach ($modelsData as $key => $modelData) |
595 | 595 | { |
596 | 596 | // set migration order |
597 | - $modelData->migrationOrder = isset($modelData->migrationOrder) ? $modelData->migrationOrder : $actualTablePosition ; |
|
597 | + $modelData->migrationOrder = isset($modelData->migrationOrder) ? $modelData->migrationOrder : $actualTablePosition; |
|
598 | 598 | |
599 | 599 | $positions = array_keys($modelsData); |
600 | 600 | |
601 | - foreach($modelData->migrationPreRequisites as $preRequiste){ |
|
601 | + foreach ($modelData->migrationPreRequisites as $preRequiste) { |
|
602 | 602 | $preRequisitePosition = array_search($preRequiste, $positions); |
603 | 603 | // change positions |
604 | - if( $preRequisitePosition > $actualTablePosition){ |
|
605 | - $modelData->migrationOrder = $preRequisitePosition ; |
|
606 | - $modelsData[$preRequiste]->migrationOrder = $actualTablePosition ; |
|
604 | + if ($preRequisitePosition > $actualTablePosition) { |
|
605 | + $modelData->migrationOrder = $preRequisitePosition; |
|
606 | + $modelsData[$preRequiste]->migrationOrder = $actualTablePosition; |
|
607 | 607 | $modelsData = Arrays::moveElement($modelsData, $preRequiste, $actualTablePosition); |
608 | 608 | |
609 | 609 | } |
@@ -611,31 +611,31 @@ discard block |
||
611 | 611 | |
612 | 612 | |
613 | 613 | // search for other fields relationships |
614 | - foreach($modelData->fields as $field){ |
|
614 | + foreach ($modelData->fields as $field) { |
|
615 | 615 | |
616 | 616 | |
617 | - if(isset($field->foreignKey->relationship)){ |
|
617 | + if (isset($field->foreignKey->relationship)) { |
|
618 | 618 | switch ($field->foreignKey->relationship) { |
619 | 619 | case 'belongsTo': |
620 | 620 | // hasOne or hasMay are the inverse relationship for belongsTo |
621 | - $relationship = new stdClass ; |
|
622 | - $relationship->type = $field->foreignKey->reverse ; |
|
623 | - $relationship->foreignKey = $field->name ; |
|
624 | - $relationship->localKey = $field->foreignKey->field ; |
|
625 | - $relationship->modelName = $modelData->modelName ; |
|
621 | + $relationship = new stdClass; |
|
622 | + $relationship->type = $field->foreignKey->reverse; |
|
623 | + $relationship->foreignKey = $field->name; |
|
624 | + $relationship->localKey = $field->foreignKey->field; |
|
625 | + $relationship->modelName = $modelData->modelName; |
|
626 | 626 | array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
627 | 627 | break; |
628 | 628 | case 'belongsToMany': |
629 | 629 | // belongsToMany is the inverse relationship for belongsTo |
630 | - $relationship = new stdClass ; |
|
631 | - $relationship->type = $field->foreignKey->reverse ; |
|
632 | - $relationship->foreignKey = $field->name ; |
|
630 | + $relationship = new stdClass; |
|
631 | + $relationship->type = $field->foreignKey->reverse; |
|
632 | + $relationship->foreignKey = $field->name; |
|
633 | 633 | $relationship->relatedTable = isset($field->relatedTable) ? $field->relatedTable : ''; |
634 | 634 | $relationship->relatedField = isset($field->relatedField) ? $field->relatedField : ''; |
635 | 635 | $relationship->ui = $field->type->ui; |
636 | - $relationship->localKey = $field->foreignKey->field ; |
|
637 | - $relationship->modelName = $modelData->modelName ; |
|
638 | - $relationship->tableName = $modelData->tableName ; |
|
636 | + $relationship->localKey = $field->foreignKey->field; |
|
637 | + $relationship->modelName = $modelData->modelName; |
|
638 | + $relationship->tableName = $modelData->tableName; |
|
639 | 639 | array_push($modelsData[$field->foreignKey->table]->reverseRelationships, $relationship); |
640 | 640 | break; |
641 | 641 | default: |
@@ -648,36 +648,36 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | |
651 | - $actualTablePosition++ ; |
|
651 | + $actualTablePosition++; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // $this->info(print_r($modelsData, 1)); |
655 | 655 | |
656 | - return $modelsData ; |
|
656 | + return $modelsData; |
|
657 | 657 | |
658 | 658 | } |
659 | 659 | |
660 | - protected function getPrimaryKeyField($modelData){ |
|
660 | + protected function getPrimaryKeyField($modelData) { |
|
661 | 661 | $primaryKey = new stdClass; |
662 | - $primaryKey->name = "id" ; |
|
663 | - $primaryKey->index = "primary" ; |
|
664 | - $primaryKey->declared = false ; |
|
665 | - $primaryKey->type = new stdClass ; |
|
666 | - $primaryKey->type->ui = 'label' ; |
|
667 | - $primaryKey->type->db = 'integer' ; |
|
662 | + $primaryKey->name = "id"; |
|
663 | + $primaryKey->index = "primary"; |
|
664 | + $primaryKey->declared = false; |
|
665 | + $primaryKey->type = new stdClass; |
|
666 | + $primaryKey->type->ui = 'label'; |
|
667 | + $primaryKey->type->db = 'integer'; |
|
668 | 668 | $primaryKey->foreignKey = []; |
669 | - $primaryKey->validations = "required" ; |
|
669 | + $primaryKey->validations = "required"; |
|
670 | 670 | |
671 | 671 | foreach ($modelData->fields as $field) |
672 | 672 | { |
673 | 673 | if ($field->index == 'primary') |
674 | 674 | { |
675 | - $primaryKey = $field ; |
|
675 | + $primaryKey = $field; |
|
676 | 676 | break; |
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
680 | - return $primaryKey ; |
|
680 | + return $primaryKey; |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | } |
684 | 684 | \ No newline at end of file |
@@ -289,8 +289,9 @@ |
||
289 | 289 | //array_push($listChooseColumnsCompilerOutput, $listChooseColumnsCompiler->compile()); |
290 | 290 | |
291 | 291 | $compiledIndexes .= $indexModuleCompiler->replaceResource($modelData); |
292 | - if ($intKey < count($modelsData)) |
|
293 | - $compiledIndexes .= ","; |
|
292 | + if ($intKey < count($modelsData)) { |
|
293 | + $compiledIndexes .= ","; |
|
294 | + } |
|
294 | 295 | |
295 | 296 | $intKey++; |
296 | 297 | // Advance progress |
@@ -116,6 +116,9 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | + /** |
|
120 | + * @param boolean $overwrite |
|
121 | + */ |
|
119 | 122 | public function copyApiFiles($overwrite) { |
120 | 123 | |
121 | 124 | $command = sprintf('cp -r %s "%s/." "%s"', |
@@ -128,6 +131,9 @@ discard block |
||
128 | 131 | $this->info('- Api files copied'); |
129 | 132 | } |
130 | 133 | |
134 | + /** |
|
135 | + * @param boolean $overwrite |
|
136 | + */ |
|
131 | 137 | public function copyAngularjsFiles($overwrite) { |
132 | 138 | |
133 | 139 | // resource angular js path |
@@ -3,15 +3,10 @@ |
||
3 | 3 | namespace Scaffolder\Commands; |
4 | 4 | |
5 | 5 | use Illuminate\Console\Command; |
6 | -use Illuminate\Support\Facades\File; |
|
7 | - |
|
8 | -use stdClass ; |
|
9 | 6 | |
10 | 7 | // Support classes |
11 | 8 | use Scaffolder\Support\Directory; |
12 | 9 | use Scaffolder\Support\Json; |
13 | -use Scaffolder\Support\Arrays; |
|
14 | -use Scaffolder\Support\CamelCase; |
|
15 | 10 | use Scaffolder\Compilers\Support\PathParser; |
16 | 11 | |
17 | 12 |
@@ -17,143 +17,143 @@ |
||
17 | 17 | |
18 | 18 | class ServeCommand extends Command |
19 | 19 | { |
20 | - protected $signature = 'scaffolder:serve {app=webapp} {--o|overwrite : Overwrite generated files} {--g|generate : Generate files }'; |
|
20 | + protected $signature = 'scaffolder:serve {app=webapp} {--o|overwrite : Overwrite generated files} {--g|generate : Generate files }'; |
|
21 | 21 | |
22 | - protected $description = 'Serve code for development purpose'; |
|
22 | + protected $description = 'Serve code for development purpose'; |
|
23 | 23 | |
24 | - // app config var |
|
25 | - private $scaffolderConfig ; |
|
24 | + // app config var |
|
25 | + private $scaffolderConfig ; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Execute the Command. |
|
29 | - */ |
|
30 | - public function handle() |
|
31 | - { |
|
32 | - // Get app config |
|
33 | - $this->getScaffolderConfig(); |
|
27 | + /** |
|
28 | + * Execute the Command. |
|
29 | + */ |
|
30 | + public function handle() |
|
31 | + { |
|
32 | + // Get app config |
|
33 | + $this->getScaffolderConfig(); |
|
34 | 34 | |
35 | - $overwrite = false; |
|
35 | + $overwrite = false; |
|
36 | 36 | |
37 | - if($this->option('overwrite')) |
|
38 | - $overwrite = true; |
|
37 | + if($this->option('overwrite')) |
|
38 | + $overwrite = true; |
|
39 | 39 | |
40 | - $generate = false; |
|
40 | + $generate = false; |
|
41 | 41 | |
42 | - if($this->option('generate')) |
|
43 | - $generate = true; |
|
42 | + if($this->option('generate')) |
|
43 | + $generate = true; |
|
44 | 44 | |
45 | 45 | |
46 | - switch ($this->argument('app')) { |
|
47 | - case 'webapp': |
|
46 | + switch ($this->argument('app')) { |
|
47 | + case 'webapp': |
|
48 | 48 | |
49 | - // gera código somente se houver a opcao |
|
50 | - if($generate) { |
|
51 | - // Gera codigo da api |
|
52 | - $this->call('scaffolder:generate', array('app' => 'api', '-c' => 'clear-all')); |
|
49 | + // gera código somente se houver a opcao |
|
50 | + if($generate) { |
|
51 | + // Gera codigo da api |
|
52 | + $this->call('scaffolder:generate', array('app' => 'api', '-c' => 'clear-all')); |
|
53 | 53 | |
54 | - // Se parametro --overwrite selecionado, copia arquivos para seu respectivo destino |
|
55 | - $this->copyApiFiles($overwrite); |
|
54 | + // Se parametro --overwrite selecionado, copia arquivos para seu respectivo destino |
|
55 | + $this->copyApiFiles($overwrite); |
|
56 | 56 | |
57 | - // Gera codigo da pasta webapp |
|
58 | - $this->call('scaffolder:generate', array('app' => 'angularjs', '-c' => 'clear-all')); |
|
57 | + // Gera codigo da pasta webapp |
|
58 | + $this->call('scaffolder:generate', array('app' => 'angularjs', '-c' => 'clear-all')); |
|
59 | 59 | |
60 | - // Se parametro --overwrite selecionado, copia arquivos para seu respectivo destino |
|
61 | - $this->copyAngularjsFiles($overwrite); |
|
62 | - } |
|
60 | + // Se parametro --overwrite selecionado, copia arquivos para seu respectivo destino |
|
61 | + $this->copyAngularjsFiles($overwrite); |
|
62 | + } |
|
63 | 63 | |
64 | - $gulpCommand = sprintf('gulp serve --cwd "%s/codificar/scaffolder-theme-material/" > null', base_path('vendor')); |
|
64 | + $gulpCommand = sprintf('gulp serve --cwd "%s/codificar/scaffolder-theme-material/" > null', base_path('vendor')); |
|
65 | 65 | |
66 | - $this->info('Running gulp in serve mode, wait your browser open...'); |
|
67 | - //$handle = popen($gulpCommand, 'r'); |
|
66 | + $this->info('Running gulp in serve mode, wait your browser open...'); |
|
67 | + //$handle = popen($gulpCommand, 'r'); |
|
68 | 68 | |
69 | - $this->launchBackgroundProcess($gulpCommand); |
|
69 | + $this->launchBackgroundProcess($gulpCommand); |
|
70 | 70 | |
71 | - // php artisan serve |
|
72 | - $this->call('serve'); |
|
71 | + // php artisan serve |
|
72 | + $this->call('serve'); |
|
73 | 73 | |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - default: |
|
77 | - $this->info('Invalid arguments'); |
|
78 | - break; |
|
79 | - } |
|
76 | + default: |
|
77 | + $this->info('Invalid arguments'); |
|
78 | + break; |
|
79 | + } |
|
80 | 80 | |
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Launch Background Process |
|
85 | - * |
|
86 | - * Launches a background process (note, provides no security itself, $call must be sanitized prior to use) |
|
87 | - * @param string $call the system call to make |
|
88 | - * @author raccettura |
|
89 | - */ |
|
90 | - private function launchBackgroundProcess($call) { |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Launch Background Process |
|
85 | + * |
|
86 | + * Launches a background process (note, provides no security itself, $call must be sanitized prior to use) |
|
87 | + * @param string $call the system call to make |
|
88 | + * @author raccettura |
|
89 | + */ |
|
90 | + private function launchBackgroundProcess($call) { |
|
91 | 91 | |
92 | - // Windows |
|
93 | - if($this->is_windows()){ |
|
94 | - pclose(popen('start /b '.$call, 'r')); |
|
95 | - } |
|
92 | + // Windows |
|
93 | + if($this->is_windows()){ |
|
94 | + pclose(popen('start /b '.$call, 'r')); |
|
95 | + } |
|
96 | 96 | |
97 | - // Some sort of UNIX |
|
98 | - else { |
|
99 | - pclose(popen($call.' /dev/null &', 'r')); |
|
100 | - } |
|
101 | - return true; |
|
102 | - } |
|
97 | + // Some sort of UNIX |
|
98 | + else { |
|
99 | + pclose(popen($call.' /dev/null &', 'r')); |
|
100 | + } |
|
101 | + return true; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * Is Windows |
|
107 | - * |
|
108 | - * Tells if we are running on Windows Platform |
|
109 | - * @author raccettura |
|
110 | - */ |
|
111 | - private function is_windows(){ |
|
112 | - if(PHP_OS == 'WINNT' || PHP_OS == 'WIN32'){ |
|
113 | - return true; |
|
114 | - } |
|
115 | - return false; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function copyApiFiles($overwrite) { |
|
120 | - |
|
121 | - $command = sprintf('cp -r %s "%s/." "%s"', |
|
122 | - (!$overwrite ? ' -u' : null) , |
|
123 | - PathParser::parse($this->scaffolderConfig->generators->api->paths->base), |
|
124 | - base_path()); |
|
105 | + /** |
|
106 | + * Is Windows |
|
107 | + * |
|
108 | + * Tells if we are running on Windows Platform |
|
109 | + * @author raccettura |
|
110 | + */ |
|
111 | + private function is_windows(){ |
|
112 | + if(PHP_OS == 'WINNT' || PHP_OS == 'WIN32'){ |
|
113 | + return true; |
|
114 | + } |
|
115 | + return false; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function copyApiFiles($overwrite) { |
|
120 | + |
|
121 | + $command = sprintf('cp -r %s "%s/." "%s"', |
|
122 | + (!$overwrite ? ' -u' : null) , |
|
123 | + PathParser::parse($this->scaffolderConfig->generators->api->paths->base), |
|
124 | + base_path()); |
|
125 | 125 | |
126 | - shell_exec($command); |
|
126 | + shell_exec($command); |
|
127 | 127 | |
128 | - $this->info('- Api files copied'); |
|
129 | - } |
|
128 | + $this->info('- Api files copied'); |
|
129 | + } |
|
130 | 130 | |
131 | - public function copyAngularjsFiles($overwrite) { |
|
131 | + public function copyAngularjsFiles($overwrite) { |
|
132 | 132 | |
133 | - // resource angular js path |
|
134 | - Directory::createIfNotExists(PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->resources), 0755, true); |
|
133 | + // resource angular js path |
|
134 | + Directory::createIfNotExists(PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->resources), 0755, true); |
|
135 | 135 | |
136 | - // copying page files |
|
137 | - $command = sprintf('cp -r %s "%s/." "%s/"', |
|
138 | - (!$overwrite ? ' -u' : null) , |
|
139 | - PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->index), |
|
140 | - PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->resources)); |
|
136 | + // copying page files |
|
137 | + $command = sprintf('cp -r %s "%s/." "%s/"', |
|
138 | + (!$overwrite ? ' -u' : null) , |
|
139 | + PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->index), |
|
140 | + PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->resources)); |
|
141 | 141 | |
142 | - shell_exec($command); |
|
142 | + shell_exec($command); |
|
143 | 143 | |
144 | - $this->info('- Angularjs files copied'); |
|
145 | - } |
|
144 | + $this->info('- Angularjs files copied'); |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | - /** |
|
149 | - * Get the app.json configuration and parse to an object |
|
150 | - * |
|
151 | - * @return void |
|
152 | - */ |
|
153 | - private function getScaffolderConfig(){ |
|
154 | - // Get app config |
|
155 | - $this->scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
|
148 | + /** |
|
149 | + * Get the app.json configuration and parse to an object |
|
150 | + * |
|
151 | + * @return void |
|
152 | + */ |
|
153 | + private function getScaffolderConfig(){ |
|
154 | + // Get app config |
|
155 | + $this->scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
|
156 | 156 | |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | \ No newline at end of file |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Illuminate\Console\Command; |
6 | 6 | use Illuminate\Support\Facades\File; |
7 | 7 | |
8 | -use stdClass ; |
|
8 | +use stdClass; |
|
9 | 9 | |
10 | 10 | // Support classes |
11 | 11 | use Scaffolder\Support\Directory; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | protected $description = 'Serve code for development purpose'; |
23 | 23 | |
24 | 24 | // app config var |
25 | - private $scaffolderConfig ; |
|
25 | + private $scaffolderConfig; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Execute the Command. |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | $overwrite = false; |
36 | 36 | |
37 | - if($this->option('overwrite')) |
|
37 | + if ($this->option('overwrite')) |
|
38 | 38 | $overwrite = true; |
39 | 39 | |
40 | 40 | $generate = false; |
41 | 41 | |
42 | - if($this->option('generate')) |
|
42 | + if ($this->option('generate')) |
|
43 | 43 | $generate = true; |
44 | 44 | |
45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | case 'webapp': |
48 | 48 | |
49 | 49 | // gera código somente se houver a opcao |
50 | - if($generate) { |
|
50 | + if ($generate) { |
|
51 | 51 | // Gera codigo da api |
52 | 52 | $this->call('scaffolder:generate', array('app' => 'api', '-c' => 'clear-all')); |
53 | 53 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | private function launchBackgroundProcess($call) { |
91 | 91 | |
92 | 92 | // Windows |
93 | - if($this->is_windows()){ |
|
93 | + if ($this->is_windows()) { |
|
94 | 94 | pclose(popen('start /b '.$call, 'r')); |
95 | 95 | } |
96 | 96 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * Tells if we are running on Windows Platform |
109 | 109 | * @author raccettura |
110 | 110 | */ |
111 | - private function is_windows(){ |
|
112 | - if(PHP_OS == 'WINNT' || PHP_OS == 'WIN32'){ |
|
111 | + private function is_windows() { |
|
112 | + if (PHP_OS == 'WINNT' || PHP_OS == 'WIN32') { |
|
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function copyApiFiles($overwrite) { |
120 | 120 | |
121 | 121 | $command = sprintf('cp -r %s "%s/." "%s"', |
122 | - (!$overwrite ? ' -u' : null) , |
|
122 | + (!$overwrite ? ' -u' : null), |
|
123 | 123 | PathParser::parse($this->scaffolderConfig->generators->api->paths->base), |
124 | 124 | base_path()); |
125 | 125 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | // copying page files |
137 | 137 | $command = sprintf('cp -r %s "%s/." "%s/"', |
138 | - (!$overwrite ? ' -u' : null) , |
|
138 | + (!$overwrite ? ' -u' : null), |
|
139 | 139 | PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->index), |
140 | 140 | PathParser::parse($this->scaffolderConfig->generators->angularjs->paths->resources)); |
141 | 141 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return void |
152 | 152 | */ |
153 | - private function getScaffolderConfig(){ |
|
153 | + private function getScaffolderConfig() { |
|
154 | 154 | // Get app config |
155 | 155 | $this->scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json')); |
156 | 156 |
@@ -34,13 +34,15 @@ |
||
34 | 34 | |
35 | 35 | $overwrite = false; |
36 | 36 | |
37 | - if($this->option('overwrite')) |
|
38 | - $overwrite = true; |
|
37 | + if($this->option('overwrite')) { |
|
38 | + $overwrite = true; |
|
39 | + } |
|
39 | 40 | |
40 | 41 | $generate = false; |
41 | 42 | |
42 | - if($this->option('generate')) |
|
43 | - $generate = true; |
|
43 | + if($this->option('generate')) { |
|
44 | + $generate = true; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | |
46 | 48 | switch ($this->argument('app')) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Replace and store the Stub. |
24 | 24 | * |
25 | - * @return string |
|
25 | + * @return IndexApiCompiler |
|
26 | 26 | */ |
27 | 27 | public function replaceAndStore() |
28 | 28 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param null $extra |
36 | 36 | * |
37 | - * @return string |
|
37 | + * @return IndexApiCompiler |
|
38 | 38 | */ |
39 | 39 | public function compile($extra = null) |
40 | 40 | { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Get output filename |
54 | 54 | * |
55 | 55 | * |
56 | - * @return $this |
|
56 | + * @return string |
|
57 | 57 | */ |
58 | 58 | protected function getOutputFilename() |
59 | 59 | { |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Scaffolder\Compilers\AbstractCompiler; |
7 | 7 | use Scaffolder\Compilers\Support\FileToCompile; |
8 | 8 | use Scaffolder\Compilers\Support\PathParser; |
9 | -use Scaffolder\Support\Directory; |
|
10 | 9 | |
11 | 10 | class IndexApiCompiler extends AbstractCompiler |
12 | 11 | { |
@@ -10,56 +10,56 @@ |
||
10 | 10 | |
11 | 11 | class IndexApiCompiler extends AbstractCompiler |
12 | 12 | { |
13 | - protected $cachePrefix = 'index_api_'; |
|
14 | - protected $stubFilename = 'IndexApi.js' ; |
|
13 | + protected $cachePrefix = 'index_api_'; |
|
14 | + protected $stubFilename = 'IndexApi.js' ; |
|
15 | 15 | |
16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
17 | - { |
|
18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
19 | - parent::__construct($scaffolderConfig, $modelData); |
|
20 | - } |
|
16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
17 | + { |
|
18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
19 | + parent::__construct($scaffolderConfig, $modelData); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Replace and store the Stub. |
|
24 | - * |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function replaceAndStore() |
|
28 | - { |
|
29 | - return $this->store(new FileToCompile(false, $this->cachePrefix)); |
|
30 | - } |
|
22 | + /** |
|
23 | + * Replace and store the Stub. |
|
24 | + * |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function replaceAndStore() |
|
28 | + { |
|
29 | + return $this->store(new FileToCompile(false, $this->cachePrefix)); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Compiles . |
|
34 | - * |
|
35 | - * @param null $extra |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function compile($extra = null) |
|
40 | - { |
|
41 | - if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . self::CACHE_EXT))) |
|
42 | - { |
|
43 | - return $this->store(new FileToCompile(true, $this->cachePrefix)); |
|
44 | - } |
|
45 | - else |
|
46 | - { |
|
32 | + /** |
|
33 | + * Compiles . |
|
34 | + * |
|
35 | + * @param null $extra |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function compile($extra = null) |
|
40 | + { |
|
41 | + if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . self::CACHE_EXT))) |
|
42 | + { |
|
43 | + return $this->store(new FileToCompile(true, $this->cachePrefix)); |
|
44 | + } |
|
45 | + else |
|
46 | + { |
|
47 | 47 | |
48 | - return $this->replaceAndStore(); |
|
49 | - } |
|
50 | - } |
|
48 | + return $this->replaceAndStore(); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get output filename |
|
54 | - * |
|
55 | - * |
|
56 | - * @return $this |
|
57 | - */ |
|
58 | - protected function getOutputFilename() |
|
59 | - { |
|
60 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->index); |
|
52 | + /** |
|
53 | + * Get output filename |
|
54 | + * |
|
55 | + * |
|
56 | + * @return $this |
|
57 | + */ |
|
58 | + protected function getOutputFilename() |
|
59 | + { |
|
60 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->index); |
|
61 | 61 | |
62 | - return $folder . 'index.api.js'; |
|
63 | - } |
|
62 | + return $folder . 'index.api.js'; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | class IndexApiCompiler extends AbstractCompiler |
12 | 12 | { |
13 | 13 | protected $cachePrefix = 'index_api_'; |
14 | - protected $stubFilename = 'IndexApi.js' ; |
|
14 | + protected $stubFilename = 'IndexApi.js'; |
|
15 | 15 | |
16 | 16 | public function __construct($scaffolderConfig, $modelData = null) |
17 | 17 | { |
18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
18 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/AngularJs/'; |
|
19 | 19 | parent::__construct($scaffolderConfig, $modelData); |
20 | 20 | } |
21 | 21 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function compile($extra = null) |
40 | 40 | { |
41 | - if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . self::CACHE_EXT))) |
|
41 | + if (File::exists(base_path('scaffolder-config/cache/'.$this->cachePrefix.self::CACHE_EXT))) |
|
42 | 42 | { |
43 | 43 | return $this->store(new FileToCompile(true, $this->cachePrefix)); |
44 | 44 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $folder = PathParser::parse($this->scaffolderConfig->generator->paths->index); |
61 | 61 | |
62 | - return $folder . 'index.api.js'; |
|
62 | + return $folder.'index.api.js'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -41,8 +41,7 @@ |
||
41 | 41 | if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . self::CACHE_EXT))) |
42 | 42 | { |
43 | 43 | return $this->store(new FileToCompile(true, $this->cachePrefix)); |
44 | - } |
|
45 | - else |
|
44 | + } else |
|
46 | 45 | { |
47 | 46 | |
48 | 47 | return $this->replaceAndStore(); |