@@ -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 |
@@ -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 |
@@ -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 | { |
@@ -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 |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * Compiles a group of routes. |
| 46 | 46 | * |
| 47 | 47 | * @param $hash |
| 48 | - * @param null $extra |
|
| 48 | + * @param string $compiledIndexes |
|
| 49 | 49 | * |
| 50 | 50 | * @return mixed |
| 51 | 51 | */ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * Get output filename |
| 64 | 64 | * |
| 65 | 65 | * |
| 66 | - * @return $this |
|
| 66 | + * @return string |
|
| 67 | 67 | */ |
| 68 | 68 | protected function getOutputFilename() |
| 69 | 69 | { |
@@ -10,98 +10,98 @@ |
||
| 10 | 10 | |
| 11 | 11 | class IndexModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $stubFilename = 'IndexModule.js' ; |
|
| 13 | + protected $stubFilename = 'IndexModule.js' ; |
|
| 14 | 14 | |
| 15 | - protected $stubResourceFilename = 'IndexModuleModel.js' ; |
|
| 16 | - protected $stubResource ; |
|
| 15 | + protected $stubResourceFilename = 'IndexModuleModel.js' ; |
|
| 16 | + protected $stubResource ; |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 20 | - { |
|
| 21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 22 | - parent::__construct($scaffolderConfig, null); |
|
| 19 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 20 | + { |
|
| 21 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 22 | + parent::__construct($scaffolderConfig, null); |
|
| 23 | 23 | |
| 24 | - $this->stubResource = File::get($this->stubsDirectory . $this->stubResourceFilename ); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Replace and store the Stub. |
|
| 29 | - * |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function replaceAndStore(){} |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Compiles a resource. |
|
| 36 | - * |
|
| 37 | - * @param $hash |
|
| 38 | - * @param null $extra |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function compile($extra = null) {} |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Compiles a group of routes. |
|
| 46 | - * |
|
| 47 | - * @param $hash |
|
| 48 | - * @param null $extra |
|
| 49 | - * |
|
| 50 | - * @return mixed |
|
| 51 | - */ |
|
| 52 | - public function compileGroup($compiledIndexes) |
|
| 53 | - { |
|
| 54 | - |
|
| 55 | - $this->replaceIndexes($compiledIndexes) |
|
| 56 | - ->store(new FileToCompile(null, null)); |
|
| 57 | - |
|
| 58 | - return $this->stub; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Get output filename |
|
| 64 | - * |
|
| 65 | - * |
|
| 66 | - * @return $this |
|
| 67 | - */ |
|
| 68 | - protected function getOutputFilename() |
|
| 69 | - { |
|
| 70 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->index); |
|
| 71 | - |
|
| 72 | - return $folder . 'index.module.js'; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Replace the resource. |
|
| 78 | - * |
|
| 79 | - * @param $this->modelName |
|
| 80 | - * |
|
| 81 | - * @return string routeStub |
|
| 82 | - */ |
|
| 83 | - public function replaceResource($modelData) |
|
| 84 | - { |
|
| 24 | + $this->stubResource = File::get($this->stubsDirectory . $this->stubResourceFilename ); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Replace and store the Stub. |
|
| 29 | + * |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function replaceAndStore(){} |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Compiles a resource. |
|
| 36 | + * |
|
| 37 | + * @param $hash |
|
| 38 | + * @param null $extra |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function compile($extra = null) {} |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Compiles a group of routes. |
|
| 46 | + * |
|
| 47 | + * @param $hash |
|
| 48 | + * @param null $extra |
|
| 49 | + * |
|
| 50 | + * @return mixed |
|
| 51 | + */ |
|
| 52 | + public function compileGroup($compiledIndexes) |
|
| 53 | + { |
|
| 54 | + |
|
| 55 | + $this->replaceIndexes($compiledIndexes) |
|
| 56 | + ->store(new FileToCompile(null, null)); |
|
| 57 | + |
|
| 58 | + return $this->stub; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Get output filename |
|
| 64 | + * |
|
| 65 | + * |
|
| 66 | + * @return $this |
|
| 67 | + */ |
|
| 68 | + protected function getOutputFilename() |
|
| 69 | + { |
|
| 70 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->index); |
|
| 71 | + |
|
| 72 | + return $folder . 'index.module.js'; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Replace the resource. |
|
| 78 | + * |
|
| 79 | + * @param $this->modelName |
|
| 80 | + * |
|
| 81 | + * @return string routeStub |
|
| 82 | + */ |
|
| 83 | + public function replaceResource($modelData) |
|
| 84 | + { |
|
| 85 | 85 | |
| 86 | - $indexStub = str_replace('{{table_name_uc}}', $modelData->modelName, $this->stubResource); |
|
| 87 | - $indexStub = str_replace('{{table_name}}', $modelData->tableName, $indexStub); |
|
| 86 | + $indexStub = str_replace('{{table_name_uc}}', $modelData->modelName, $this->stubResource); |
|
| 87 | + $indexStub = str_replace('{{table_name}}', $modelData->tableName, $indexStub); |
|
| 88 | 88 | |
| 89 | - return $indexStub; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Replace compiled routes. |
|
| 94 | - * |
|
| 95 | - * @param $compiledRoutes |
|
| 96 | - * |
|
| 97 | - * @return $this |
|
| 98 | - */ |
|
| 99 | - private function replaceIndexes($compiledIndexes) |
|
| 100 | - { |
|
| 101 | - $this->stub = str_replace('{{tables}}', $compiledIndexes, $this->stub); |
|
| 102 | - |
|
| 103 | - return $this; |
|
| 104 | - } |
|
| 89 | + return $indexStub; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Replace compiled routes. |
|
| 94 | + * |
|
| 95 | + * @param $compiledRoutes |
|
| 96 | + * |
|
| 97 | + * @return $this |
|
| 98 | + */ |
|
| 99 | + private function replaceIndexes($compiledIndexes) |
|
| 100 | + { |
|
| 101 | + $this->stub = str_replace('{{tables}}', $compiledIndexes, $this->stub); |
|
| 102 | + |
|
| 103 | + return $this; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return ListChooseColumnsCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Get output filename |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @return $this |
|
| 38 | + * @return string |
|
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
@@ -10,40 +10,40 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ListChooseColumnsCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'list_choose_column_'; |
|
| 14 | - protected $stubFilename = 'ChooseColumnsDialog.html' ; |
|
| 15 | - |
|
| 16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | - { |
|
| 18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Replace and store the Stub. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function replaceAndStore() |
|
| 28 | - { |
|
| 13 | + protected $cachePrefix = 'list_choose_column_'; |
|
| 14 | + protected $stubFilename = 'ChooseColumnsDialog.html' ; |
|
| 15 | + |
|
| 16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | + { |
|
| 18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Replace and store the Stub. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function replaceAndStore() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get output filename |
|
| 36 | - * |
|
| 37 | - * |
|
| 38 | - * @return $this |
|
| 39 | - */ |
|
| 40 | - protected function getOutputFilename() |
|
| 41 | - { |
|
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | - |
|
| 44 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | - |
|
| 46 | - return $folder .$this->modelData->tableName . '_columns.dialog.html'; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * Get output filename |
|
| 36 | + * |
|
| 37 | + * |
|
| 38 | + * @return $this |
|
| 39 | + */ |
|
| 40 | + protected function getOutputFilename() |
|
| 41 | + { |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | + |
|
| 44 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | + |
|
| 46 | + return $folder .$this->modelData->tableName . '_columns.dialog.html'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return ListControllerCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Get output filename |
| 78 | 78 | * |
| 79 | 79 | * |
| 80 | - * @return $this |
|
| 80 | + * @return string |
|
| 81 | 81 | */ |
| 82 | 82 | protected function getOutputFilename() |
| 83 | 83 | { |
@@ -10,82 +10,82 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ListControllerCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'list_controller_'; |
|
| 14 | - protected $stubFilename = 'ListController.js' ; |
|
| 15 | - |
|
| 16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | - { |
|
| 18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Replace and store the Stub. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function replaceAndStore() |
|
| 28 | - { |
|
| 13 | + protected $cachePrefix = 'list_controller_'; |
|
| 14 | + protected $stubFilename = 'ListController.js' ; |
|
| 15 | + |
|
| 16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | + { |
|
| 18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Replace and store the Stub. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function replaceAndStore() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - return $this->replaceColumns() |
|
| 31 | - ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this->replaceColumns() |
|
| 31 | + ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 32 | 32 | |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * replace columns |
|
| 37 | - * |
|
| 38 | - * @return $this |
|
| 39 | - */ |
|
| 40 | - public function replaceColumns(){ |
|
| 35 | + /** |
|
| 36 | + * replace columns |
|
| 37 | + * |
|
| 38 | + * @return $this |
|
| 39 | + */ |
|
| 40 | + public function replaceColumns(){ |
|
| 41 | 41 | |
| 42 | - $columns = $this->getGridColumns(); |
|
| 42 | + $columns = $this->getGridColumns(); |
|
| 43 | 43 | |
| 44 | - $this->stub = str_replace('{{grid_columns}}', join(",\n ", $columns) , $this->stub); |
|
| 44 | + $this->stub = str_replace('{{grid_columns}}', join(",\n ", $columns) , $this->stub); |
|
| 45 | 45 | |
| 46 | - return $this ; |
|
| 46 | + return $this ; |
|
| 47 | 47 | |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getGridColumns(){ |
|
| 50 | + public function getGridColumns(){ |
|
| 51 | 51 | |
| 52 | - $columns = []; |
|
| 52 | + $columns = []; |
|
| 53 | 53 | |
| 54 | - foreach ($this->modelData->fields as $field) |
|
| 55 | - { |
|
| 56 | - array_push($columns, "\t\t\t".sprintf('{ name: vm. $t("%s.columns.%s"), field: "%s%s" }', $this->modelData->tableName, $field->name, $this->eagerTable, $field->name ) ); |
|
| 54 | + foreach ($this->modelData->fields as $field) |
|
| 55 | + { |
|
| 56 | + array_push($columns, "\t\t\t".sprintf('{ name: vm. $t("%s.columns.%s"), field: "%s%s" }', $this->modelData->tableName, $field->name, $this->eagerTable, $field->name ) ); |
|
| 57 | 57 | |
| 58 | - // Check foreign key |
|
| 59 | - if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 60 | - { |
|
| 61 | - // search eager fields |
|
| 62 | - $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 63 | - $foreignControllerCompiler = new ListControllerCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 64 | - $foreignControllerCompiler->setEagerTable($field->foreignKey->table); |
|
| 65 | - $eagerColumns = $foreignControllerCompiler->getGridColumns(); |
|
| 58 | + // Check foreign key |
|
| 59 | + if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 60 | + { |
|
| 61 | + // search eager fields |
|
| 62 | + $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 63 | + $foreignControllerCompiler = new ListControllerCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 64 | + $foreignControllerCompiler->setEagerTable($field->foreignKey->table); |
|
| 65 | + $eagerColumns = $foreignControllerCompiler->getGridColumns(); |
|
| 66 | 66 | |
| 67 | - $columns = array_merge($columns, $eagerColumns); |
|
| 68 | - } |
|
| 69 | - } |
|
| 67 | + $columns = array_merge($columns, $eagerColumns); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $columns; |
|
| 71 | + return $columns; |
|
| 72 | 72 | |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Get output filename |
|
| 78 | - * |
|
| 79 | - * |
|
| 80 | - * @return $this |
|
| 81 | - */ |
|
| 82 | - protected function getOutputFilename() |
|
| 83 | - { |
|
| 84 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 85 | - |
|
| 86 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 87 | - |
|
| 88 | - return $folder .$this->modelData->tableName . '_list.controller.js'; |
|
| 89 | - } |
|
| 76 | + /** |
|
| 77 | + * Get output filename |
|
| 78 | + * |
|
| 79 | + * |
|
| 80 | + * @return $this |
|
| 81 | + */ |
|
| 82 | + protected function getOutputFilename() |
|
| 83 | + { |
|
| 84 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 85 | + |
|
| 86 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 87 | + |
|
| 88 | + return $folder .$this->modelData->tableName . '_list.controller.js'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return ListDetailCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Get output filename |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @return $this |
|
| 38 | + * @return string |
|
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
@@ -10,40 +10,40 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ListDetailCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'list_detail_'; |
|
| 14 | - protected $stubFilename = 'DetailDialog.html' ; |
|
| 15 | - |
|
| 16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | - { |
|
| 18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Replace and store the Stub. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function replaceAndStore() |
|
| 28 | - { |
|
| 13 | + protected $cachePrefix = 'list_detail_'; |
|
| 14 | + protected $stubFilename = 'DetailDialog.html' ; |
|
| 15 | + |
|
| 16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | + { |
|
| 18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Replace and store the Stub. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function replaceAndStore() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get output filename |
|
| 36 | - * |
|
| 37 | - * |
|
| 38 | - * @return $this |
|
| 39 | - */ |
|
| 40 | - protected function getOutputFilename() |
|
| 41 | - { |
|
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | - |
|
| 44 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | - |
|
| 46 | - return $folder .$this->modelData->tableName . '_details.dialog.html'; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * Get output filename |
|
| 36 | + * |
|
| 37 | + * |
|
| 38 | + * @return $this |
|
| 39 | + */ |
|
| 40 | + protected function getOutputFilename() |
|
| 41 | + { |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | + |
|
| 44 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | + |
|
| 46 | + return $folder .$this->modelData->tableName . '_details.dialog.html'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return ListModuleCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Get output filename |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @return $this |
|
| 38 | + * @return string |
|
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
@@ -10,40 +10,40 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ListModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'list_module_'; |
|
| 14 | - protected $stubFilename = 'ListModule.js' ; |
|
| 15 | - |
|
| 16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | - { |
|
| 18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Replace and store the Stub. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function replaceAndStore() |
|
| 28 | - { |
|
| 13 | + protected $cachePrefix = 'list_module_'; |
|
| 14 | + protected $stubFilename = 'ListModule.js' ; |
|
| 15 | + |
|
| 16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | + { |
|
| 18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Replace and store the Stub. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function replaceAndStore() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get output filename |
|
| 36 | - * |
|
| 37 | - * |
|
| 38 | - * @return $this |
|
| 39 | - */ |
|
| 40 | - protected function getOutputFilename() |
|
| 41 | - { |
|
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | - |
|
| 44 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | - |
|
| 46 | - return $folder .$this->modelData->tableName . '_list.module.js'; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * Get output filename |
|
| 36 | + * |
|
| 37 | + * |
|
| 38 | + * @return $this |
|
| 39 | + */ |
|
| 40 | + protected function getOutputFilename() |
|
| 41 | + { |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 43 | + |
|
| 44 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | + |
|
| 46 | + return $folder .$this->modelData->tableName . '_list.module.js'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * Replace and store the Stub. |
| 27 | 27 | * |
| 28 | - * @return string |
|
| 28 | + * @return ListTemplateCompiler |
|
| 29 | 29 | */ |
| 30 | 30 | public function replaceAndStore() |
| 31 | 31 | { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * get search conditions |
| 55 | 55 | * |
| 56 | - * @return $this |
|
| 56 | + * @return string |
|
| 57 | 57 | */ |
| 58 | 58 | public function getInputFields(){ |
| 59 | 59 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string $field |
| 98 | 98 | * @param string $fieldStub |
| 99 | 99 | * |
| 100 | - * @return $this |
|
| 100 | + * @return string |
|
| 101 | 101 | */ |
| 102 | 102 | protected function replaceFieldInput($field, $fieldStub){ |
| 103 | 103 | $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string $field |
| 113 | 113 | * @param string $fieldStub |
| 114 | 114 | * |
| 115 | - * @return $this |
|
| 115 | + * @return string |
|
| 116 | 116 | */ |
| 117 | 117 | protected function replaceFieldValidations($field, $fieldStub){ |
| 118 | 118 | $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * Get output filename |
| 200 | 200 | * |
| 201 | 201 | * |
| 202 | - * @return $this |
|
| 202 | + * @return string |
|
| 203 | 203 | */ |
| 204 | 204 | protected function getOutputFilename() |
| 205 | 205 | { |
@@ -13,201 +13,201 @@ |
||
| 13 | 13 | |
| 14 | 14 | class ListTemplateCompiler extends AbstractCompiler |
| 15 | 15 | { |
| 16 | - protected $cachePrefix = 'list_template_'; |
|
| 17 | - protected $stubFilename = 'ListTemplate.html' ; |
|
| 18 | - |
|
| 19 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 20 | - { |
|
| 21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 22 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Replace and store the Stub. |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function replaceAndStore() |
|
| 31 | - { |
|
| 16 | + protected $cachePrefix = 'list_template_'; |
|
| 17 | + protected $stubFilename = 'ListTemplate.html' ; |
|
| 18 | + |
|
| 19 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 20 | + { |
|
| 21 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 22 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Replace and store the Stub. |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function replaceAndStore() |
|
| 31 | + { |
|
| 32 | 32 | |
| 33 | - return $this->replaceInputFields() |
|
| 34 | - ->replaceBelongsToManyFields() |
|
| 35 | - ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 33 | + return $this->replaceInputFields() |
|
| 34 | + ->replaceBelongsToManyFields() |
|
| 35 | + ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 36 | 36 | |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Replace input fields |
|
| 41 | - * |
|
| 42 | - * @return $this |
|
| 43 | - */ |
|
| 44 | - private function replaceInputFields(){ |
|
| 39 | + /** |
|
| 40 | + * Replace input fields |
|
| 41 | + * |
|
| 42 | + * @return $this |
|
| 43 | + */ |
|
| 44 | + private function replaceInputFields(){ |
|
| 45 | 45 | |
| 46 | - $inputFields = $this->getInputFields(); |
|
| 46 | + $inputFields = $this->getInputFields(); |
|
| 47 | 47 | |
| 48 | - $this->stub = str_replace('{{columns_inputs}}', $inputFields, $this->stub); |
|
| 48 | + $this->stub = str_replace('{{columns_inputs}}', $inputFields, $this->stub); |
|
| 49 | 49 | |
| 50 | - return $this; |
|
| 51 | - } |
|
| 50 | + return $this; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * get search conditions |
|
| 55 | - * |
|
| 56 | - * @return $this |
|
| 57 | - */ |
|
| 58 | - public function getInputFields(){ |
|
| 53 | + /** |
|
| 54 | + * get search conditions |
|
| 55 | + * |
|
| 56 | + * @return $this |
|
| 57 | + */ |
|
| 58 | + public function getInputFields(){ |
|
| 59 | 59 | |
| 60 | - $inputFields = $eagerFields = ''; |
|
| 60 | + $inputFields = $eagerFields = ''; |
|
| 61 | 61 | |
| 62 | - foreach ($this->modelData->fields as $field) |
|
| 63 | - { |
|
| 64 | - $fieldStub = $this->getInputStubByField($field); |
|
| 62 | + foreach ($this->modelData->fields as $field) |
|
| 63 | + { |
|
| 64 | + $fieldStub = $this->getInputStubByField($field); |
|
| 65 | 65 | |
| 66 | - if($field->foreignKey){ |
|
| 67 | - $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 68 | - $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
|
| 69 | - } |
|
| 66 | + if($field->foreignKey){ |
|
| 67 | + $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 68 | + $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 71 | + $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 72 | 72 | |
| 73 | - // Check foreign key |
|
| 74 | - if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 75 | - { |
|
| 76 | - // search eager fields |
|
| 77 | - $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 78 | - $foreignControllerCompiler = new ListTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 79 | - $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
|
| 80 | - $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 81 | - } |
|
| 73 | + // Check foreign key |
|
| 74 | + if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 75 | + { |
|
| 76 | + // search eager fields |
|
| 77 | + $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 78 | + $foreignControllerCompiler = new ListTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 79 | + $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
|
| 80 | + $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // replace table name |
|
| 86 | - $inputFields = str_replace('{{table_name}}', $this->modelData->tableName, $inputFields); |
|
| 85 | + // replace table name |
|
| 86 | + $inputFields = str_replace('{{table_name}}', $this->modelData->tableName, $inputFields); |
|
| 87 | 87 | |
| 88 | - $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
|
| 89 | - |
|
| 90 | - return $inputFields ; |
|
| 91 | - |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * replace field stub with fields and validations |
|
| 96 | - * |
|
| 97 | - * @param string $field |
|
| 98 | - * @param string $fieldStub |
|
| 99 | - * |
|
| 100 | - * @return $this |
|
| 101 | - */ |
|
| 102 | - protected function replaceFieldInput($field, $fieldStub){ |
|
| 103 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 104 | - $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 105 | - |
|
| 106 | - return $fieldStub ; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * replace field stub with fields and validations |
|
| 111 | - * |
|
| 112 | - * @param string $field |
|
| 113 | - * @param string $fieldStub |
|
| 114 | - * |
|
| 115 | - * @return $this |
|
| 116 | - */ |
|
| 117 | - protected function replaceFieldValidations($field, $fieldStub){ |
|
| 118 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 88 | + $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
|
| 89 | + |
|
| 90 | + return $inputFields ; |
|
| 91 | + |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * replace field stub with fields and validations |
|
| 96 | + * |
|
| 97 | + * @param string $field |
|
| 98 | + * @param string $fieldStub |
|
| 99 | + * |
|
| 100 | + * @return $this |
|
| 101 | + */ |
|
| 102 | + protected function replaceFieldInput($field, $fieldStub){ |
|
| 103 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 104 | + $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 105 | + |
|
| 106 | + return $fieldStub ; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * replace field stub with fields and validations |
|
| 111 | + * |
|
| 112 | + * @param string $field |
|
| 113 | + * @param string $fieldStub |
|
| 114 | + * |
|
| 115 | + * @return $this |
|
| 116 | + */ |
|
| 117 | + protected function replaceFieldValidations($field, $fieldStub){ |
|
| 118 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 119 | 119 | |
| 120 | - $validationsConverted = Validator::convertValidations($field->validations, true); |
|
| 120 | + $validationsConverted = Validator::convertValidations($field->validations, true); |
|
| 121 | 121 | |
| 122 | - $inputValidations = '' ; |
|
| 122 | + $inputValidations = '' ; |
|
| 123 | 123 | |
| 124 | - foreach ($validationsConverted as $attribute => $value) { |
|
| 125 | - if($value) |
|
| 126 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | - else |
|
| 128 | - $inputValidations .= ' '.$attribute ; |
|
| 129 | - } |
|
| 124 | + foreach ($validationsConverted as $attribute => $value) { |
|
| 125 | + if($value) |
|
| 126 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | + else |
|
| 128 | + $inputValidations .= ' '.$attribute ; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
|
| 131 | + $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
|
| 132 | 132 | |
| 133 | - return $fieldStub ; |
|
| 134 | - } |
|
| 133 | + return $fieldStub ; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Replace belongs to many fields |
|
| 138 | - * |
|
| 139 | - * @return $this |
|
| 140 | - */ |
|
| 141 | - protected function replaceBelongsToManyFields() { |
|
| 136 | + /** |
|
| 137 | + * Replace belongs to many fields |
|
| 138 | + * |
|
| 139 | + * @return $this |
|
| 140 | + */ |
|
| 141 | + protected function replaceBelongsToManyFields() { |
|
| 142 | 142 | |
| 143 | - $belongToManyFields = ''; |
|
| 143 | + $belongToManyFields = ''; |
|
| 144 | 144 | |
| 145 | - foreach ($this->modelData->reverseRelationships as $relationship) |
|
| 146 | - { |
|
| 147 | - if ($relationship->type == "belongsToMany") { |
|
| 148 | - $fieldStub = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 149 | - |
|
| 150 | - $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 151 | - $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
|
| 152 | - $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
|
| 153 | - $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
|
| 145 | + foreach ($this->modelData->reverseRelationships as $relationship) |
|
| 146 | + { |
|
| 147 | + if ($relationship->type == "belongsToMany") { |
|
| 148 | + $fieldStub = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 149 | + |
|
| 150 | + $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 151 | + $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
|
| 152 | + $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
|
| 153 | + $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
|
| 154 | 154 | |
| 155 | - $belongToManyFields .= $fieldStub; |
|
| 156 | - } |
|
| 157 | - } |
|
| 155 | + $belongToManyFields .= $fieldStub; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - $this->stub = str_replace('{{belongs_to_many_inputs}}', $belongToManyFields, $this->stub); |
|
| 159 | + $this->stub = str_replace('{{belongs_to_many_inputs}}', $belongToManyFields, $this->stub); |
|
| 160 | 160 | |
| 161 | - return $this; |
|
| 162 | - } |
|
| 161 | + return $this; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * get input field stub by ui type |
|
| 167 | - * |
|
| 168 | - * @param string $field |
|
| 169 | - * |
|
| 170 | - * @return $this |
|
| 171 | - */ |
|
| 172 | - private $inputStub = []; |
|
| 173 | - private function getInputStubByField($field){ |
|
| 165 | + /** |
|
| 166 | + * get input field stub by ui type |
|
| 167 | + * |
|
| 168 | + * @param string $field |
|
| 169 | + * |
|
| 170 | + * @return $this |
|
| 171 | + */ |
|
| 172 | + private $inputStub = []; |
|
| 173 | + private function getInputStubByField($field){ |
|
| 174 | 174 | |
| 175 | - if($field->index == 'primary'){ |
|
| 176 | - $uiType = 'primary' ; |
|
| 177 | - } |
|
| 178 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 179 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 180 | - $uiType = 'foreign_eager' ; |
|
| 181 | - else |
|
| 182 | - $uiType = $field->type->ui ; |
|
| 183 | - } |
|
| 184 | - else { |
|
| 185 | - $uiType = $field->type->ui ; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - if(array_key_exists($uiType, $this->inputStub)){ |
|
| 189 | - return $this->inputStub[$uiType]; |
|
| 190 | - } |
|
| 191 | - else { |
|
| 192 | - $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 193 | - |
|
| 194 | - return $this->inputStub[$uiType]; |
|
| 195 | - } |
|
| 196 | - } |
|
| 175 | + if($field->index == 'primary'){ |
|
| 176 | + $uiType = 'primary' ; |
|
| 177 | + } |
|
| 178 | + elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 179 | + if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 180 | + $uiType = 'foreign_eager' ; |
|
| 181 | + else |
|
| 182 | + $uiType = $field->type->ui ; |
|
| 183 | + } |
|
| 184 | + else { |
|
| 185 | + $uiType = $field->type->ui ; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + if(array_key_exists($uiType, $this->inputStub)){ |
|
| 189 | + return $this->inputStub[$uiType]; |
|
| 190 | + } |
|
| 191 | + else { |
|
| 192 | + $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 193 | + |
|
| 194 | + return $this->inputStub[$uiType]; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Get output filename |
|
| 200 | - * |
|
| 201 | - * |
|
| 202 | - * @return $this |
|
| 203 | - */ |
|
| 204 | - protected function getOutputFilename() |
|
| 205 | - { |
|
| 206 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 207 | - |
|
| 208 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 209 | - |
|
| 210 | - return $folder .$this->modelData->tableName . '_list.html'; |
|
| 211 | - } |
|
| 198 | + /** |
|
| 199 | + * Get output filename |
|
| 200 | + * |
|
| 201 | + * |
|
| 202 | + * @return $this |
|
| 203 | + */ |
|
| 204 | + protected function getOutputFilename() |
|
| 205 | + { |
|
| 206 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 207 | + |
|
| 208 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 209 | + |
|
| 210 | + return $folder .$this->modelData->tableName . '_list.html'; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return ModuleCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Get output filename |
| 36 | 36 | * |
| 37 | 37 | * |
| 38 | - * @return $this |
|
| 38 | + * @return string |
|
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
@@ -10,40 +10,40 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'module_'; |
|
| 14 | - protected $stubFilename = 'Module.js' ; |
|
| 15 | - |
|
| 16 | - public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | - { |
|
| 18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | - parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Replace and store the Stub. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function replaceAndStore() |
|
| 28 | - { |
|
| 13 | + protected $cachePrefix = 'module_'; |
|
| 14 | + protected $stubFilename = 'Module.js' ; |
|
| 15 | + |
|
| 16 | + public function __construct($scaffolderConfig, $modelData = null) |
|
| 17 | + { |
|
| 18 | + $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 19 | + parent::__construct($scaffolderConfig, $modelData); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Replace and store the Stub. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function replaceAndStore() |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get output filename |
|
| 36 | - * |
|
| 37 | - * |
|
| 38 | - * @return $this |
|
| 39 | - */ |
|
| 40 | - protected function getOutputFilename() |
|
| 41 | - { |
|
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/' ; |
|
| 43 | - |
|
| 44 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | - |
|
| 46 | - return $folder . $this->modelData->tableName . '.module.js'; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * Get output filename |
|
| 36 | + * |
|
| 37 | + * |
|
| 38 | + * @return $this |
|
| 39 | + */ |
|
| 40 | + protected function getOutputFilename() |
|
| 41 | + { |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/' ; |
|
| 43 | + |
|
| 44 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | + |
|
| 46 | + return $folder . $this->modelData->tableName . '.module.js'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |