@@ -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 | { |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -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 |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class ListChooseColumnsCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'list_choose_column_'; |
| 14 | - protected $stubFilename = 'ChooseColumnsDialog.html' ; |
|
| 14 | + protected $stubFilename = 'ChooseColumnsDialog.html'; |
|
| 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 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/'; |
|
| 43 | 43 | |
| 44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
| 45 | 45 | |
| 46 | - return $folder .$this->modelData->tableName . '_columns.dialog.html'; |
|
| 46 | + return $folder.$this->modelData->tableName.'_columns.dialog.html'; |
|
| 47 | 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 |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class ListControllerCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'list_controller_'; |
| 14 | - protected $stubFilename = 'ListController.js' ; |
|
| 14 | + protected $stubFilename = 'ListController.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 | |
@@ -37,23 +37,23 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return $this |
| 39 | 39 | */ |
| 40 | - public function replaceColumns(){ |
|
| 40 | + public function replaceColumns() { |
|
| 41 | 41 | |
| 42 | 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 | 52 | $columns = []; |
| 53 | 53 | |
| 54 | 54 | foreach ($this->modelData->fields as $field) |
| 55 | 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 ) ); |
|
| 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 | 58 | // Check foreign key |
| 59 | 59 | if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $foreignModelData = $this->getModelData($field->foreignKey->table); |
| 63 | 63 | $foreignControllerCompiler = new ListControllerCompiler($this->scaffolderConfig, $foreignModelData); |
| 64 | 64 | $foreignControllerCompiler->setEagerTable($field->foreignKey->table); |
| 65 | - $eagerColumns = $foreignControllerCompiler->getGridColumns(); |
|
| 65 | + $eagerColumns = $foreignControllerCompiler->getGridColumns(); |
|
| 66 | 66 | |
| 67 | 67 | $columns = array_merge($columns, $eagerColumns); |
| 68 | 68 | } |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function getOutputFilename() |
| 83 | 83 | { |
| 84 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 84 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/'; |
|
| 85 | 85 | |
| 86 | 86 | Directory::createIfNotExists($folder, 0755, true); |
| 87 | 87 | |
| 88 | - return $folder .$this->modelData->tableName . '_list.controller.js'; |
|
| 88 | + return $folder.$this->modelData->tableName.'_list.controller.js'; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -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 |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class ListDetailCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'list_detail_'; |
| 14 | - protected $stubFilename = 'DetailDialog.html' ; |
|
| 14 | + protected $stubFilename = 'DetailDialog.html'; |
|
| 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 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/'; |
|
| 43 | 43 | |
| 44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
| 45 | 45 | |
| 46 | - return $folder .$this->modelData->tableName . '_details.dialog.html'; |
|
| 46 | + return $folder.$this->modelData->tableName.'_details.dialog.html'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -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 |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class ListModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'list_module_'; |
| 14 | - protected $stubFilename = 'ListModule.js' ; |
|
| 14 | + protected $stubFilename = 'ListModule.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 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/'; |
|
| 43 | 43 | |
| 44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
| 45 | 45 | |
| 46 | - return $folder .$this->modelData->tableName . '_list.module.js'; |
|
| 46 | + return $folder.$this->modelData->tableName.'_list.module.js'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -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 | { |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use Scaffolder\Support\Directory; |
| 10 | 10 | use Scaffolder\Support\CamelCase; |
| 11 | 11 | use Scaffolder\Support\Validator; |
| 12 | -use stdClass ; |
|
| 13 | 12 | |
| 14 | 13 | class ListTemplateCompiler extends AbstractCompiler |
| 15 | 14 | { |
@@ -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 |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | use Scaffolder\Support\Directory; |
| 10 | 10 | use Scaffolder\Support\CamelCase; |
| 11 | 11 | use Scaffolder\Support\Validator; |
| 12 | -use stdClass ; |
|
| 12 | +use stdClass; |
|
| 13 | 13 | |
| 14 | 14 | class ListTemplateCompiler extends AbstractCompiler |
| 15 | 15 | { |
| 16 | 16 | protected $cachePrefix = 'list_template_'; |
| 17 | - protected $stubFilename = 'ListTemplate.html' ; |
|
| 17 | + protected $stubFilename = 'ListTemplate.html'; |
|
| 18 | 18 | |
| 19 | 19 | public function __construct($scaffolderConfig, $modelData = null) |
| 20 | 20 | { |
| 21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 21 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/AngularJs/'; |
|
| 22 | 22 | parent::__construct($scaffolderConfig, $modelData); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return $this |
| 43 | 43 | */ |
| 44 | - private function replaceInputFields(){ |
|
| 44 | + private function replaceInputFields() { |
|
| 45 | 45 | |
| 46 | 46 | $inputFields = $this->getInputFields(); |
| 47 | 47 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return $this |
| 57 | 57 | */ |
| 58 | - public function getInputFields(){ |
|
| 58 | + public function getInputFields() { |
|
| 59 | 59 | |
| 60 | 60 | $inputFields = $eagerFields = ''; |
| 61 | 61 | |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | $fieldStub = $this->getInputStubByField($field); |
| 65 | 65 | |
| 66 | - if($field->foreignKey){ |
|
| 67 | - $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 66 | + if ($field->foreignKey) { |
|
| 67 | + $fieldStub = $this->replaceForeingStrings($field, $fieldStub); |
|
| 68 | 68 | $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 71 | + $inputFields .= $this->replaceFieldInput($field, $fieldStub); |
|
| 72 | 72 | |
| 73 | 73 | // Check foreign key |
| 74 | 74 | if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $foreignModelData = $this->getModelData($field->foreignKey->table); |
| 78 | 78 | $foreignControllerCompiler = new ListTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
| 79 | 79 | $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
| 80 | - $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 80 | + $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
| 89 | 89 | |
| 90 | - return $inputFields ; |
|
| 90 | + return $inputFields; |
|
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return $this |
| 101 | 101 | */ |
| 102 | - protected function replaceFieldInput($field, $fieldStub){ |
|
| 103 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 104 | - $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 102 | + protected function replaceFieldInput($field, $fieldStub) { |
|
| 103 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub); |
|
| 104 | + $fieldStub = $this->replaceFieldValidations($field, $fieldStub); |
|
| 105 | 105 | |
| 106 | - return $fieldStub ; |
|
| 106 | + return $fieldStub; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return $this |
| 116 | 116 | */ |
| 117 | - protected function replaceFieldValidations($field, $fieldStub){ |
|
| 118 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 117 | + protected function replaceFieldValidations($field, $fieldStub) { |
|
| 118 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub); |
|
| 119 | 119 | |
| 120 | 120 | $validationsConverted = Validator::convertValidations($field->validations, true); |
| 121 | 121 | |
| 122 | - $inputValidations = '' ; |
|
| 122 | + $inputValidations = ''; |
|
| 123 | 123 | |
| 124 | 124 | foreach ($validationsConverted as $attribute => $value) { |
| 125 | - if($value) |
|
| 126 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 125 | + if ($value) |
|
| 126 | + $inputValidations .= ' '.$attribute.'="'.$value.'"'; |
|
| 127 | 127 | else |
| 128 | - $inputValidations .= ' '.$attribute ; |
|
| 128 | + $inputValidations .= ' '.$attribute; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
| 132 | 132 | |
| 133 | - return $fieldStub ; |
|
| 133 | + return $fieldStub; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | foreach ($this->modelData->reverseRelationships as $relationship) |
| 146 | 146 | { |
| 147 | 147 | if ($relationship->type == "belongsToMany") { |
| 148 | - $fieldStub = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 148 | + $fieldStub = File::get($this->stubsDirectory.'List/'.CamelCase::convertToCamelCase($relationship->ui).'.html'); |
|
| 149 | 149 | |
| 150 | - $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 150 | + $fieldStub = str_replace('{{related_table}}', CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 151 | 151 | $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
| 152 | 152 | $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
| 153 | 153 | $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
@@ -170,26 +170,26 @@ discard block |
||
| 170 | 170 | * @return $this |
| 171 | 171 | */ |
| 172 | 172 | private $inputStub = []; |
| 173 | - private function getInputStubByField($field){ |
|
| 173 | + private function getInputStubByField($field) { |
|
| 174 | 174 | |
| 175 | - if($field->index == 'primary'){ |
|
| 176 | - $uiType = 'primary' ; |
|
| 175 | + if ($field->index == 'primary') { |
|
| 176 | + $uiType = 'primary'; |
|
| 177 | 177 | } |
| 178 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 179 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 180 | - $uiType = 'foreign_eager' ; |
|
| 178 | + elseif (isset($field->foreignKey) && $field->foreignKey) { |
|
| 179 | + if (isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 180 | + $uiType = 'foreign_eager'; |
|
| 181 | 181 | else |
| 182 | - $uiType = $field->type->ui ; |
|
| 182 | + $uiType = $field->type->ui; |
|
| 183 | 183 | } |
| 184 | 184 | else { |
| 185 | - $uiType = $field->type->ui ; |
|
| 185 | + $uiType = $field->type->ui; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if(array_key_exists($uiType, $this->inputStub)){ |
|
| 188 | + if (array_key_exists($uiType, $this->inputStub)) { |
|
| 189 | 189 | return $this->inputStub[$uiType]; |
| 190 | 190 | } |
| 191 | 191 | else { |
| 192 | - $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 192 | + $this->inputStub[$uiType] = File::get($this->stubsDirectory.'List/'.CamelCase::convertToCamelCase($uiType).'.html'); |
|
| 193 | 193 | |
| 194 | 194 | return $this->inputStub[$uiType]; |
| 195 | 195 | } |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | protected function getOutputFilename() |
| 205 | 205 | { |
| 206 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/' ; |
|
| 206 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/list/'; |
|
| 207 | 207 | |
| 208 | 208 | Directory::createIfNotExists($folder, 0755, true); |
| 209 | 209 | |
| 210 | - return $folder .$this->modelData->tableName . '_list.html'; |
|
| 210 | + return $folder.$this->modelData->tableName.'_list.html'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | \ No newline at end of file |
@@ -122,10 +122,11 @@ discard block |
||
| 122 | 122 | $inputValidations = '' ; |
| 123 | 123 | |
| 124 | 124 | foreach ($validationsConverted as $attribute => $value) { |
| 125 | - if($value) |
|
| 126 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | - else |
|
| 128 | - $inputValidations .= ' '.$attribute ; |
|
| 125 | + if($value) { |
|
| 126 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | + } else { |
|
| 128 | + $inputValidations .= ' '.$attribute ; |
|
| 129 | + } |
|
| 129 | 130 | } |
| 130 | 131 | |
| 131 | 132 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
@@ -174,21 +175,19 @@ discard block |
||
| 174 | 175 | |
| 175 | 176 | if($field->index == 'primary'){ |
| 176 | 177 | $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 { |
|
| 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 | 185 | $uiType = $field->type->ui ; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if(array_key_exists($uiType, $this->inputStub)){ |
| 189 | 189 | return $this->inputStub[$uiType]; |
| 190 | - } |
|
| 191 | - else { |
|
| 190 | + } else { |
|
| 192 | 191 | $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html'); |
| 193 | 192 | |
| 194 | 193 | return $this->inputStub[$uiType]; |
@@ -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 |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class ModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'module_'; |
| 14 | - protected $stubFilename = 'Module.js' ; |
|
| 14 | + protected $stubFilename = 'Module.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 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/' ; |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/'; |
|
| 43 | 43 | |
| 44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
| 45 | 45 | |
| 46 | - return $folder . $this->modelData->tableName . '.module.js'; |
|
| 46 | + return $folder.$this->modelData->tableName.'.module.js'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Replace and store the Stub. |
| 24 | 24 | * |
| 25 | - * @return string |
|
| 25 | + * @return RegisterControllerCompiler |
|
| 26 | 26 | */ |
| 27 | 27 | public function replaceAndStore() |
| 28 | 28 | { |
@@ -114,6 +114,10 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
| 117 | + /** |
|
| 118 | + * @param string $stubName |
|
| 119 | + * @param string $stubTag |
|
| 120 | + */ |
|
| 117 | 121 | public function changeStubDataAndTag($stubName,$stubTag,$table_from) |
| 118 | 122 | { |
| 119 | 123 | $stubFile = File::get($this->stubsDirectory . '/Register/'.$stubName.'ControllerStub.php'); |
@@ -125,7 +129,7 @@ discard block |
||
| 125 | 129 | * Get output filename |
| 126 | 130 | * |
| 127 | 131 | * |
| 128 | - * @return $this |
|
| 132 | + * @return string |
|
| 129 | 133 | */ |
| 130 | 134 | protected function getOutputFilename() |
| 131 | 135 | { |
@@ -10,130 +10,130 @@ |
||
| 10 | 10 | |
| 11 | 11 | class RegisterControllerCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'register_controller_'; |
|
| 14 | - protected $stubFilename = 'RegisterController.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 = 'register_controller_'; |
|
| 14 | + protected $stubFilename = 'RegisterController.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 |
|
| 31 | - ->replaceFileUpload() |
|
| 32 | - ->replaceNewTags() |
|
| 33 | - ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 30 | + return $this |
|
| 31 | + ->replaceFileUpload() |
|
| 32 | + ->replaceNewTags() |
|
| 33 | + ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 34 | 34 | |
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function replaceNewTags() |
|
| 38 | - { |
|
| 39 | - foreach ($this->modelData->fields as $field) |
|
| 40 | - { |
|
| 41 | - |
|
| 42 | - if($field->type->ui == 'autoComplete' || $field->type->ui == 'multipleAutoComplete') |
|
| 43 | - { |
|
| 44 | - $this->stub = str_replace('{{table_from}}', $field->table_from, $this->stub); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return $this; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - private function replaceFileUpload() |
|
| 54 | - { |
|
| 55 | - $fileStub = File::get($this->stubsDirectory . '/Register/FileRegisterControllerStub.php'); |
|
| 56 | - $this->stub = str_replace('{{file_upload}}', $fileStub, $this->stub); |
|
| 57 | - |
|
| 58 | - $keyAutoComplete = $keyMultipleAutoComplete = $keyCheckbox = $keyCheckboxTree = false; |
|
| 59 | - |
|
| 60 | - foreach ($this->modelData->fields as $field) |
|
| 61 | - { |
|
| 62 | - |
|
| 63 | - //Verifica os tipos de UI no model.json e realiza a troca das tags pelas funções JS se necessário |
|
| 64 | - switch ($field->type->ui) { |
|
| 65 | - case 'autoComplete': |
|
| 66 | - $autoStub = $this->changeStubDataAndTag('AutoComplete', '{{auto_complete}}', $field->table_from); |
|
| 67 | - $keyAutoComplete = true; |
|
| 68 | - break; |
|
| 69 | - case 'multipleAutoComplete': |
|
| 70 | - $multipleAutoStub = $this->changeStubDataAndTag('MultipleAutoComplete','{{multiple_auto_complete}}',$field->table_from); |
|
| 71 | - $keyMultipleAutoComplete = true; |
|
| 72 | - break; |
|
| 73 | - case 'checkbox': |
|
| 74 | - $checkboxStub = $this->changeStubDataAndTag('Checkbox','{{checkbox}}', $field->table_from); |
|
| 75 | - $keyCheckbox = true; |
|
| 76 | - break; |
|
| 77 | - case 'checkboxTree': |
|
| 78 | - $checkboxTreeStub = $this->changeStubDataAndTag('CheckboxTree','{{checkbox_tree}}', $field->table_from); |
|
| 79 | - $keyCheckboxTree = true; |
|
| 80 | - break; |
|
| 81 | - default: |
|
| 82 | - break; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if($field->foreignKey) |
|
| 86 | - { |
|
| 87 | - $this->stub = str_replace('{{foreign_table}}', $field->foreignKey->table, $this->stub); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function replaceNewTags() |
|
| 38 | + { |
|
| 39 | + foreach ($this->modelData->fields as $field) |
|
| 40 | + { |
|
| 41 | + |
|
| 42 | + if($field->type->ui == 'autoComplete' || $field->type->ui == 'multipleAutoComplete') |
|
| 43 | + { |
|
| 44 | + $this->stub = str_replace('{{table_from}}', $field->table_from, $this->stub); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + return $this; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + private function replaceFileUpload() |
|
| 54 | + { |
|
| 55 | + $fileStub = File::get($this->stubsDirectory . '/Register/FileRegisterControllerStub.php'); |
|
| 56 | + $this->stub = str_replace('{{file_upload}}', $fileStub, $this->stub); |
|
| 57 | + |
|
| 58 | + $keyAutoComplete = $keyMultipleAutoComplete = $keyCheckbox = $keyCheckboxTree = false; |
|
| 59 | + |
|
| 60 | + foreach ($this->modelData->fields as $field) |
|
| 61 | + { |
|
| 62 | + |
|
| 63 | + //Verifica os tipos de UI no model.json e realiza a troca das tags pelas funções JS se necessário |
|
| 64 | + switch ($field->type->ui) { |
|
| 65 | + case 'autoComplete': |
|
| 66 | + $autoStub = $this->changeStubDataAndTag('AutoComplete', '{{auto_complete}}', $field->table_from); |
|
| 67 | + $keyAutoComplete = true; |
|
| 68 | + break; |
|
| 69 | + case 'multipleAutoComplete': |
|
| 70 | + $multipleAutoStub = $this->changeStubDataAndTag('MultipleAutoComplete','{{multiple_auto_complete}}',$field->table_from); |
|
| 71 | + $keyMultipleAutoComplete = true; |
|
| 72 | + break; |
|
| 73 | + case 'checkbox': |
|
| 74 | + $checkboxStub = $this->changeStubDataAndTag('Checkbox','{{checkbox}}', $field->table_from); |
|
| 75 | + $keyCheckbox = true; |
|
| 76 | + break; |
|
| 77 | + case 'checkboxTree': |
|
| 78 | + $checkboxTreeStub = $this->changeStubDataAndTag('CheckboxTree','{{checkbox_tree}}', $field->table_from); |
|
| 79 | + $keyCheckboxTree = true; |
|
| 80 | + break; |
|
| 81 | + default: |
|
| 82 | + break; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if($field->foreignKey) |
|
| 86 | + { |
|
| 87 | + $this->stub = str_replace('{{foreign_table}}', $field->foreignKey->table, $this->stub); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if(!$keyAutoComplete) |
|
| 94 | - { |
|
| 95 | - $this->stub = str_replace('{{auto_complete}}', ' ', $this->stub); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if(!$keyMultipleAutoComplete) |
|
| 99 | - { |
|
| 100 | - $this->stub = str_replace('{{multiple_auto_complete}}', ' ', $this->stub); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if(!$keyCheckbox) |
|
| 104 | - { |
|
| 105 | - $this->stub = str_replace('{{checkbox}}', ' ', $this->stub); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if(!$keyCheckboxTree) |
|
| 109 | - { |
|
| 110 | - $this->stub = str_replace('{{checkbox_tree}}', ' ', $this->stub); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - return $this; |
|
| 114 | - } |
|
| 93 | + if(!$keyAutoComplete) |
|
| 94 | + { |
|
| 95 | + $this->stub = str_replace('{{auto_complete}}', ' ', $this->stub); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if(!$keyMultipleAutoComplete) |
|
| 99 | + { |
|
| 100 | + $this->stub = str_replace('{{multiple_auto_complete}}', ' ', $this->stub); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if(!$keyCheckbox) |
|
| 104 | + { |
|
| 105 | + $this->stub = str_replace('{{checkbox}}', ' ', $this->stub); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if(!$keyCheckboxTree) |
|
| 109 | + { |
|
| 110 | + $this->stub = str_replace('{{checkbox_tree}}', ' ', $this->stub); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + return $this; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | - public function changeStubDataAndTag($stubName,$stubTag,$table_from) |
|
| 118 | - { |
|
| 119 | - $stubFile = File::get($this->stubsDirectory . '/Register/'.$stubName.'ControllerStub.php'); |
|
| 120 | - $stubFile = str_replace('{{table_from}}', $table_from, $stubFile); |
|
| 121 | - $this->stub = str_replace($stubTag, $stubFile, $this->stub); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Get output filename |
|
| 126 | - * |
|
| 127 | - * |
|
| 128 | - * @return $this |
|
| 129 | - */ |
|
| 130 | - protected function getOutputFilename() |
|
| 131 | - { |
|
| 132 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 133 | - |
|
| 134 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 135 | - |
|
| 136 | - return $folder .$this->modelData->tableName . '_register.controller.js'; |
|
| 137 | - } |
|
| 117 | + public function changeStubDataAndTag($stubName,$stubTag,$table_from) |
|
| 118 | + { |
|
| 119 | + $stubFile = File::get($this->stubsDirectory . '/Register/'.$stubName.'ControllerStub.php'); |
|
| 120 | + $stubFile = str_replace('{{table_from}}', $table_from, $stubFile); |
|
| 121 | + $this->stub = str_replace($stubTag, $stubFile, $this->stub); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Get output filename |
|
| 126 | + * |
|
| 127 | + * |
|
| 128 | + * @return $this |
|
| 129 | + */ |
|
| 130 | + protected function getOutputFilename() |
|
| 131 | + { |
|
| 132 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 133 | + |
|
| 134 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 135 | + |
|
| 136 | + return $folder .$this->modelData->tableName . '_register.controller.js'; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | \ No newline at end of file |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class RegisterControllerCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'register_controller_'; |
| 14 | - protected $stubFilename = 'RegisterController.js' ; |
|
| 14 | + protected $stubFilename = 'RegisterController.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 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | foreach ($this->modelData->fields as $field) |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - if($field->type->ui == 'autoComplete' || $field->type->ui == 'multipleAutoComplete') |
|
| 42 | + if ($field->type->ui == 'autoComplete' || $field->type->ui == 'multipleAutoComplete') |
|
| 43 | 43 | { |
| 44 | 44 | $this->stub = str_replace('{{table_from}}', $field->table_from, $this->stub); |
| 45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private function replaceFileUpload() |
| 54 | 54 | { |
| 55 | - $fileStub = File::get($this->stubsDirectory . '/Register/FileRegisterControllerStub.php'); |
|
| 55 | + $fileStub = File::get($this->stubsDirectory.'/Register/FileRegisterControllerStub.php'); |
|
| 56 | 56 | $this->stub = str_replace('{{file_upload}}', $fileStub, $this->stub); |
| 57 | 57 | |
| 58 | 58 | $keyAutoComplete = $keyMultipleAutoComplete = $keyCheckbox = $keyCheckboxTree = false; |
@@ -67,22 +67,22 @@ discard block |
||
| 67 | 67 | $keyAutoComplete = true; |
| 68 | 68 | break; |
| 69 | 69 | case 'multipleAutoComplete': |
| 70 | - $multipleAutoStub = $this->changeStubDataAndTag('MultipleAutoComplete','{{multiple_auto_complete}}',$field->table_from); |
|
| 70 | + $multipleAutoStub = $this->changeStubDataAndTag('MultipleAutoComplete', '{{multiple_auto_complete}}', $field->table_from); |
|
| 71 | 71 | $keyMultipleAutoComplete = true; |
| 72 | 72 | break; |
| 73 | 73 | case 'checkbox': |
| 74 | - $checkboxStub = $this->changeStubDataAndTag('Checkbox','{{checkbox}}', $field->table_from); |
|
| 74 | + $checkboxStub = $this->changeStubDataAndTag('Checkbox', '{{checkbox}}', $field->table_from); |
|
| 75 | 75 | $keyCheckbox = true; |
| 76 | 76 | break; |
| 77 | 77 | case 'checkboxTree': |
| 78 | - $checkboxTreeStub = $this->changeStubDataAndTag('CheckboxTree','{{checkbox_tree}}', $field->table_from); |
|
| 78 | + $checkboxTreeStub = $this->changeStubDataAndTag('CheckboxTree', '{{checkbox_tree}}', $field->table_from); |
|
| 79 | 79 | $keyCheckboxTree = true; |
| 80 | 80 | break; |
| 81 | 81 | default: |
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if($field->foreignKey) |
|
| 85 | + if ($field->foreignKey) |
|
| 86 | 86 | { |
| 87 | 87 | $this->stub = str_replace('{{foreign_table}}', $field->foreignKey->table, $this->stub); |
| 88 | 88 | } |
@@ -90,22 +90,22 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if(!$keyAutoComplete) |
|
| 93 | + if (!$keyAutoComplete) |
|
| 94 | 94 | { |
| 95 | 95 | $this->stub = str_replace('{{auto_complete}}', ' ', $this->stub); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if(!$keyMultipleAutoComplete) |
|
| 98 | + if (!$keyMultipleAutoComplete) |
|
| 99 | 99 | { |
| 100 | 100 | $this->stub = str_replace('{{multiple_auto_complete}}', ' ', $this->stub); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if(!$keyCheckbox) |
|
| 103 | + if (!$keyCheckbox) |
|
| 104 | 104 | { |
| 105 | 105 | $this->stub = str_replace('{{checkbox}}', ' ', $this->stub); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(!$keyCheckboxTree) |
|
| 108 | + if (!$keyCheckboxTree) |
|
| 109 | 109 | { |
| 110 | 110 | $this->stub = str_replace('{{checkbox_tree}}', ' ', $this->stub); |
| 111 | 111 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
| 117 | - public function changeStubDataAndTag($stubName,$stubTag,$table_from) |
|
| 117 | + public function changeStubDataAndTag($stubName, $stubTag, $table_from) |
|
| 118 | 118 | { |
| 119 | - $stubFile = File::get($this->stubsDirectory . '/Register/'.$stubName.'ControllerStub.php'); |
|
| 119 | + $stubFile = File::get($this->stubsDirectory.'/Register/'.$stubName.'ControllerStub.php'); |
|
| 120 | 120 | $stubFile = str_replace('{{table_from}}', $table_from, $stubFile); |
| 121 | 121 | $this->stub = str_replace($stubTag, $stubFile, $this->stub); |
| 122 | 122 | } |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | protected function getOutputFilename() |
| 131 | 131 | { |
| 132 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 132 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/'; |
|
| 133 | 133 | |
| 134 | 134 | Directory::createIfNotExists($folder, 0755, true); |
| 135 | 135 | |
| 136 | - return $folder .$this->modelData->tableName . '_register.controller.js'; |
|
| 136 | + return $folder.$this->modelData->tableName.'_register.controller.js'; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | \ 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 RegisterModuleCompiler |
|
| 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 RegisterModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | - protected $cachePrefix = 'register_module_'; |
|
| 14 | - protected $stubFilename = 'RegisterModule.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 = 'register_module_'; |
|
| 14 | + protected $stubFilename = 'RegisterModule.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.'/register/' ; |
|
| 43 | - |
|
| 44 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | - |
|
| 46 | - return $folder .$this->modelData->tableName . '_register.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.'/register/' ; |
|
| 43 | + |
|
| 44 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 45 | + |
|
| 46 | + return $folder .$this->modelData->tableName . '_register.module.js'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | class RegisterModuleCompiler extends AbstractCompiler |
| 12 | 12 | { |
| 13 | 13 | protected $cachePrefix = 'register_module_'; |
| 14 | - protected $stubFilename = 'RegisterModule.js' ; |
|
| 14 | + protected $stubFilename = 'RegisterModule.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 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function getOutputFilename() |
| 41 | 41 | { |
| 42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/'; |
|
| 43 | 43 | |
| 44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
| 45 | 45 | |
| 46 | - return $folder .$this->modelData->tableName . '_register.module.js'; |
|
| 46 | + return $folder.$this->modelData->tableName.'_register.module.js'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Scaffolder\Compilers\AngularJs; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\File; |
|
| 6 | 5 | use Scaffolder\Compilers\AbstractCompiler; |
| 7 | 6 | use Scaffolder\Compilers\Support\FileToCompile; |
| 8 | 7 | use Scaffolder\Compilers\Support\PathParser; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * Replace and store the Stub. |
| 27 | 27 | * |
| 28 | - * @return string |
|
| 28 | + * @return RegisterTemplateCompiler |
|
| 29 | 29 | */ |
| 30 | 30 | public function replaceAndStore() |
| 31 | 31 | { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * get search conditions |
| 56 | 56 | * |
| 57 | - * @return $this |
|
| 57 | + * @return string |
|
| 58 | 58 | */ |
| 59 | 59 | public function getInputFields(){ |
| 60 | 60 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $field |
| 129 | 129 | * @param string $fieldStub |
| 130 | 130 | * |
| 131 | - * @return $this |
|
| 131 | + * @return string |
|
| 132 | 132 | */ |
| 133 | 133 | protected function replaceFieldInput($field, $fieldStub){ |
| 134 | 134 | $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param string $field |
| 144 | 144 | * @param string $fieldStub |
| 145 | 145 | * |
| 146 | - * @return $this |
|
| 146 | + * @return string |
|
| 147 | 147 | */ |
| 148 | 148 | protected function replaceFieldValidations($field, $fieldStub){ |
| 149 | 149 | $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * Get output filename |
| 203 | 203 | * |
| 204 | 204 | * |
| 205 | - * @return $this |
|
| 205 | + * @return string |
|
| 206 | 206 | */ |
| 207 | 207 | protected function getOutputFilename() |
| 208 | 208 | { |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use Scaffolder\Support\Directory; |
| 10 | 10 | use Scaffolder\Support\CamelCase; |
| 11 | 11 | use Scaffolder\Support\Validator; |
| 12 | -use stdClass ; |
|
| 13 | 12 | |
| 14 | 13 | class RegisterTemplateCompiler extends AbstractCompiler |
| 15 | 14 | { |
@@ -13,204 +13,204 @@ |
||
| 13 | 13 | |
| 14 | 14 | class RegisterTemplateCompiler extends AbstractCompiler |
| 15 | 15 | { |
| 16 | - protected $cachePrefix = 'register_template_'; |
|
| 17 | - protected $stubFilename = 'RegisterTemplate.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 = 'register_template_'; |
|
| 17 | + protected $stubFilename = 'RegisterTemplate.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 |
|
| 34 | - ->replaceInputFields() |
|
| 35 | - ->replaceBelongsToManyFields() |
|
| 36 | - ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 33 | + return $this |
|
| 34 | + ->replaceInputFields() |
|
| 35 | + ->replaceBelongsToManyFields() |
|
| 36 | + ->store(new FileToCompile(false, $this->modelData->modelHash)); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Replace input fields |
|
| 42 | - * |
|
| 43 | - * @return $this |
|
| 44 | - */ |
|
| 45 | - private function replaceInputFields(){ |
|
| 40 | + /** |
|
| 41 | + * Replace input fields |
|
| 42 | + * |
|
| 43 | + * @return $this |
|
| 44 | + */ |
|
| 45 | + private function replaceInputFields(){ |
|
| 46 | 46 | |
| 47 | - $inputFields = $this->getInputFields(); |
|
| 47 | + $inputFields = $this->getInputFields(); |
|
| 48 | 48 | |
| 49 | - $this->stub = str_replace('{{columns_inputs}}', $inputFields, $this->stub); |
|
| 49 | + $this->stub = str_replace('{{columns_inputs}}', $inputFields, $this->stub); |
|
| 50 | 50 | |
| 51 | - return $this; |
|
| 52 | - } |
|
| 51 | + return $this; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * get search conditions |
|
| 56 | - * |
|
| 57 | - * @return $this |
|
| 58 | - */ |
|
| 59 | - public function getInputFields(){ |
|
| 54 | + /** |
|
| 55 | + * get search conditions |
|
| 56 | + * |
|
| 57 | + * @return $this |
|
| 58 | + */ |
|
| 59 | + public function getInputFields(){ |
|
| 60 | 60 | |
| 61 | - $inputFields = $eagerFields = ''; |
|
| 61 | + $inputFields = $eagerFields = ''; |
|
| 62 | 62 | |
| 63 | - foreach ($this->modelData->fields as $field) |
|
| 64 | - { |
|
| 65 | - $fieldStub = $this->getInputStubByField($field); |
|
| 63 | + foreach ($this->modelData->fields as $field) |
|
| 64 | + { |
|
| 65 | + $fieldStub = $this->getInputStubByField($field); |
|
| 66 | 66 | |
| 67 | - if($field->foreignKey){ |
|
| 67 | + if($field->foreignKey){ |
|
| 68 | 68 | |
| 69 | - $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 70 | - $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 74 | - |
|
| 75 | - // Check foreign key |
|
| 76 | - if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 77 | - { |
|
| 78 | - // search eager fields |
|
| 79 | - $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 80 | - $foreignControllerCompiler = new RegisterTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 81 | - $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
|
| 82 | - $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // replace table name |
|
| 88 | - $inputFields = str_replace('{{table_name}}', $this->modelData->tableName, $inputFields); |
|
| 69 | + $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 70 | + $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 74 | + |
|
| 75 | + // Check foreign key |
|
| 76 | + if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 77 | + { |
|
| 78 | + // search eager fields |
|
| 79 | + $foreignModelData = $this->getModelData($field->foreignKey->table); |
|
| 80 | + $foreignControllerCompiler = new RegisterTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
|
| 81 | + $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
|
| 82 | + $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // replace table name |
|
| 88 | + $inputFields = str_replace('{{table_name}}', $this->modelData->tableName, $inputFields); |
|
| 89 | 89 | |
| 90 | - $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
|
| 90 | + $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
|
| 91 | 91 | |
| 92 | - return $inputFields ; |
|
| 92 | + return $inputFields ; |
|
| 93 | 93 | |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Replace belongs to many fields |
|
| 98 | - * |
|
| 99 | - * @return $this |
|
| 100 | - */ |
|
| 101 | - protected function replaceBelongsToManyFields() { |
|
| 96 | + /** |
|
| 97 | + * Replace belongs to many fields |
|
| 98 | + * |
|
| 99 | + * @return $this |
|
| 100 | + */ |
|
| 101 | + protected function replaceBelongsToManyFields() { |
|
| 102 | 102 | |
| 103 | - $belongToManyFields = ''; |
|
| 103 | + $belongToManyFields = ''; |
|
| 104 | 104 | |
| 105 | - foreach ($this->modelData->reverseRelationships as $relationship) |
|
| 106 | - { |
|
| 107 | - if ($relationship->type == "belongsToMany") { |
|
| 108 | - $fieldStub = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 109 | - |
|
| 110 | - $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 111 | - $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
|
| 112 | - $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
|
| 113 | - $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
|
| 114 | - $fieldStub = str_replace('{{foreign_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->modelName)), $fieldStub); |
|
| 105 | + foreach ($this->modelData->reverseRelationships as $relationship) |
|
| 106 | + { |
|
| 107 | + if ($relationship->type == "belongsToMany") { |
|
| 108 | + $fieldStub = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 109 | + |
|
| 110 | + $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 111 | + $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
|
| 112 | + $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
|
| 113 | + $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
|
| 114 | + $fieldStub = str_replace('{{foreign_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->modelName)), $fieldStub); |
|
| 115 | 115 | |
| 116 | - $belongToManyFields .= $fieldStub; |
|
| 117 | - } |
|
| 118 | - } |
|
| 116 | + $belongToManyFields .= $fieldStub; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - $this->stub = str_replace('{{belongs_to_many_inputs}}', $belongToManyFields, $this->stub); |
|
| 120 | + $this->stub = str_replace('{{belongs_to_many_inputs}}', $belongToManyFields, $this->stub); |
|
| 121 | 121 | |
| 122 | - return $this; |
|
| 123 | - } |
|
| 122 | + return $this; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * replace field stub with fields and validations |
|
| 127 | - * |
|
| 128 | - * @param string $field |
|
| 129 | - * @param string $fieldStub |
|
| 130 | - * |
|
| 131 | - * @return $this |
|
| 132 | - */ |
|
| 133 | - protected function replaceFieldInput($field, $fieldStub){ |
|
| 134 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 135 | - $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 136 | - |
|
| 137 | - return $fieldStub ; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * replace field stub with fields and validations |
|
| 142 | - * |
|
| 143 | - * @param string $field |
|
| 144 | - * @param string $fieldStub |
|
| 145 | - * |
|
| 146 | - * @return $this |
|
| 147 | - */ |
|
| 148 | - protected function replaceFieldValidations($field, $fieldStub){ |
|
| 149 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 125 | + /** |
|
| 126 | + * replace field stub with fields and validations |
|
| 127 | + * |
|
| 128 | + * @param string $field |
|
| 129 | + * @param string $fieldStub |
|
| 130 | + * |
|
| 131 | + * @return $this |
|
| 132 | + */ |
|
| 133 | + protected function replaceFieldInput($field, $fieldStub){ |
|
| 134 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 135 | + $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 136 | + |
|
| 137 | + return $fieldStub ; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * replace field stub with fields and validations |
|
| 142 | + * |
|
| 143 | + * @param string $field |
|
| 144 | + * @param string $fieldStub |
|
| 145 | + * |
|
| 146 | + * @return $this |
|
| 147 | + */ |
|
| 148 | + protected function replaceFieldValidations($field, $fieldStub){ |
|
| 149 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 150 | 150 | |
| 151 | - $validationsConverted = Validator::convertValidations($field->validations); |
|
| 151 | + $validationsConverted = Validator::convertValidations($field->validations); |
|
| 152 | 152 | |
| 153 | - $inputValidations = '' ; |
|
| 153 | + $inputValidations = '' ; |
|
| 154 | 154 | |
| 155 | - foreach ($validationsConverted as $attribute => $value) { |
|
| 156 | - if($value) |
|
| 157 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 158 | - else |
|
| 159 | - $inputValidations .= ' '.$attribute ; |
|
| 160 | - } |
|
| 155 | + foreach ($validationsConverted as $attribute => $value) { |
|
| 156 | + if($value) |
|
| 157 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 158 | + else |
|
| 159 | + $inputValidations .= ' '.$attribute ; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
|
| 162 | + $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
|
| 163 | 163 | |
| 164 | - return $fieldStub ; |
|
| 165 | - } |
|
| 164 | + return $fieldStub ; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * get input field stub by ui type |
|
| 170 | - * |
|
| 171 | - * @param string $field |
|
| 172 | - * |
|
| 173 | - * @return $this |
|
| 174 | - */ |
|
| 175 | - private $inputStub = []; |
|
| 176 | - private function getInputStubByField($field){ |
|
| 168 | + /** |
|
| 169 | + * get input field stub by ui type |
|
| 170 | + * |
|
| 171 | + * @param string $field |
|
| 172 | + * |
|
| 173 | + * @return $this |
|
| 174 | + */ |
|
| 175 | + private $inputStub = []; |
|
| 176 | + private function getInputStubByField($field){ |
|
| 177 | 177 | |
| 178 | - if($field->index == 'primary'){ |
|
| 179 | - $uiType = 'primary' ; |
|
| 180 | - } |
|
| 181 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 182 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 183 | - $uiType = 'foreign_eager' ; |
|
| 184 | - else |
|
| 185 | - $uiType = $field->type->ui ; |
|
| 186 | - } |
|
| 187 | - else { |
|
| 188 | - $uiType = $field->type->ui ; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - if(array_key_exists($uiType, $this->inputStub)){ |
|
| 192 | - return $this->inputStub[$uiType]; |
|
| 193 | - } |
|
| 194 | - else { |
|
| 195 | - $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 196 | - |
|
| 197 | - return $this->inputStub[$uiType]; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Get output filename |
|
| 203 | - * |
|
| 204 | - * |
|
| 205 | - * @return $this |
|
| 206 | - */ |
|
| 207 | - protected function getOutputFilename() |
|
| 208 | - { |
|
| 209 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 210 | - |
|
| 211 | - Directory::createIfNotExists($folder, 0755, true); |
|
| 212 | - |
|
| 213 | - return $folder .$this->modelData->tableName . '_register.html'; |
|
| 214 | - } |
|
| 178 | + if($field->index == 'primary'){ |
|
| 179 | + $uiType = 'primary' ; |
|
| 180 | + } |
|
| 181 | + elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 182 | + if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 183 | + $uiType = 'foreign_eager' ; |
|
| 184 | + else |
|
| 185 | + $uiType = $field->type->ui ; |
|
| 186 | + } |
|
| 187 | + else { |
|
| 188 | + $uiType = $field->type->ui ; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + if(array_key_exists($uiType, $this->inputStub)){ |
|
| 192 | + return $this->inputStub[$uiType]; |
|
| 193 | + } |
|
| 194 | + else { |
|
| 195 | + $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 196 | + |
|
| 197 | + return $this->inputStub[$uiType]; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Get output filename |
|
| 203 | + * |
|
| 204 | + * |
|
| 205 | + * @return $this |
|
| 206 | + */ |
|
| 207 | + protected function getOutputFilename() |
|
| 208 | + { |
|
| 209 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 210 | + |
|
| 211 | + Directory::createIfNotExists($folder, 0755, true); |
|
| 212 | + |
|
| 213 | + return $folder .$this->modelData->tableName . '_register.html'; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | \ No newline at end of file |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | use Scaffolder\Support\Directory; |
| 10 | 10 | use Scaffolder\Support\CamelCase; |
| 11 | 11 | use Scaffolder\Support\Validator; |
| 12 | -use stdClass ; |
|
| 12 | +use stdClass; |
|
| 13 | 13 | |
| 14 | 14 | class RegisterTemplateCompiler extends AbstractCompiler |
| 15 | 15 | { |
| 16 | 16 | protected $cachePrefix = 'register_template_'; |
| 17 | - protected $stubFilename = 'RegisterTemplate.html' ; |
|
| 17 | + protected $stubFilename = 'RegisterTemplate.html'; |
|
| 18 | 18 | |
| 19 | 19 | public function __construct($scaffolderConfig, $modelData = null) |
| 20 | 20 | { |
| 21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
| 21 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/AngularJs/'; |
|
| 22 | 22 | parent::__construct($scaffolderConfig, $modelData); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return $this |
| 44 | 44 | */ |
| 45 | - private function replaceInputFields(){ |
|
| 45 | + private function replaceInputFields() { |
|
| 46 | 46 | |
| 47 | 47 | $inputFields = $this->getInputFields(); |
| 48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return $this |
| 58 | 58 | */ |
| 59 | - public function getInputFields(){ |
|
| 59 | + public function getInputFields() { |
|
| 60 | 60 | |
| 61 | 61 | $inputFields = $eagerFields = ''; |
| 62 | 62 | |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $fieldStub = $this->getInputStubByField($field); |
| 66 | 66 | |
| 67 | - if($field->foreignKey){ |
|
| 67 | + if ($field->foreignKey) { |
|
| 68 | 68 | |
| 69 | - $fieldStub = $this->replaceForeingStrings($field, $fieldStub) ; |
|
| 69 | + $fieldStub = $this->replaceForeingStrings($field, $fieldStub); |
|
| 70 | 70 | $fieldStub = str_replace('{{foreign_model_name}}', strtolower(CamelCase::convertToCamelCase($field->foreignKey->table)), $fieldStub); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $inputFields .= $this->replaceFieldInput($field, $fieldStub) ; |
|
| 73 | + $inputFields .= $this->replaceFieldInput($field, $fieldStub); |
|
| 74 | 74 | |
| 75 | 75 | // Check foreign key |
| 76 | 76 | if ($field->foreignKey && isset($field->foreignKey->eager) && $field->foreignKey->eager) |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $foreignModelData = $this->getModelData($field->foreignKey->table); |
| 80 | 80 | $foreignControllerCompiler = new RegisterTemplateCompiler($this->scaffolderConfig, $foreignModelData); |
| 81 | 81 | $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
| 82 | - $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 82 | + $eagerFields .= $foreignControllerCompiler->getInputFields(); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $this->stub = str_replace('{{eager_objects_inputs}}', $eagerFields, $this->stub); |
| 91 | 91 | |
| 92 | - return $inputFields ; |
|
| 92 | + return $inputFields; |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | foreach ($this->modelData->reverseRelationships as $relationship) |
| 106 | 106 | { |
| 107 | 107 | if ($relationship->type == "belongsToMany") { |
| 108 | - $fieldStub = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($relationship->ui). '.html'); |
|
| 108 | + $fieldStub = File::get($this->stubsDirectory.'Register/'.CamelCase::convertToCamelCase($relationship->ui).'.html'); |
|
| 109 | 109 | |
| 110 | - $fieldStub = str_replace('{{related_table}}',CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 110 | + $fieldStub = str_replace('{{related_table}}', CamelCase::convertToCamelCase($relationship->relatedTable), $fieldStub); |
|
| 111 | 111 | $fieldStub = str_replace('{{related_table_lw}}', strtolower(CamelCase::convertToCamelCase($relationship->relatedTable)), $fieldStub); |
| 112 | 112 | $fieldStub = str_replace('{{table_name}}', $this->modelData->tableName, $fieldStub); |
| 113 | 113 | $fieldStub = str_replace('{{related_table_lw_pl}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $fieldStub); |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return $this |
| 132 | 132 | */ |
| 133 | - protected function replaceFieldInput($field, $fieldStub){ |
|
| 134 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 135 | - $fieldStub = $this->replaceFieldValidations($field, $fieldStub) ; |
|
| 133 | + protected function replaceFieldInput($field, $fieldStub) { |
|
| 134 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub); |
|
| 135 | + $fieldStub = $this->replaceFieldValidations($field, $fieldStub); |
|
| 136 | 136 | |
| 137 | - return $fieldStub ; |
|
| 137 | + return $fieldStub; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -145,23 +145,23 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return $this |
| 147 | 147 | */ |
| 148 | - protected function replaceFieldValidations($field, $fieldStub){ |
|
| 149 | - $fieldStub = $this->replaceFieldStrings($field, $fieldStub) ; |
|
| 148 | + protected function replaceFieldValidations($field, $fieldStub) { |
|
| 149 | + $fieldStub = $this->replaceFieldStrings($field, $fieldStub); |
|
| 150 | 150 | |
| 151 | 151 | $validationsConverted = Validator::convertValidations($field->validations); |
| 152 | 152 | |
| 153 | - $inputValidations = '' ; |
|
| 153 | + $inputValidations = ''; |
|
| 154 | 154 | |
| 155 | 155 | foreach ($validationsConverted as $attribute => $value) { |
| 156 | - if($value) |
|
| 157 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 156 | + if ($value) |
|
| 157 | + $inputValidations .= ' '.$attribute.'="'.$value.'"'; |
|
| 158 | 158 | else |
| 159 | - $inputValidations .= ' '.$attribute ; |
|
| 159 | + $inputValidations .= ' '.$attribute; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
| 163 | 163 | |
| 164 | - return $fieldStub ; |
|
| 164 | + return $fieldStub; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | * @return $this |
| 174 | 174 | */ |
| 175 | 175 | private $inputStub = []; |
| 176 | - private function getInputStubByField($field){ |
|
| 176 | + private function getInputStubByField($field) { |
|
| 177 | 177 | |
| 178 | - if($field->index == 'primary'){ |
|
| 179 | - $uiType = 'primary' ; |
|
| 178 | + if ($field->index == 'primary') { |
|
| 179 | + $uiType = 'primary'; |
|
| 180 | 180 | } |
| 181 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 182 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 183 | - $uiType = 'foreign_eager' ; |
|
| 181 | + elseif (isset($field->foreignKey) && $field->foreignKey) { |
|
| 182 | + if (isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 183 | + $uiType = 'foreign_eager'; |
|
| 184 | 184 | else |
| 185 | - $uiType = $field->type->ui ; |
|
| 185 | + $uiType = $field->type->ui; |
|
| 186 | 186 | } |
| 187 | 187 | else { |
| 188 | - $uiType = $field->type->ui ; |
|
| 188 | + $uiType = $field->type->ui; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if(array_key_exists($uiType, $this->inputStub)){ |
|
| 191 | + if (array_key_exists($uiType, $this->inputStub)) { |
|
| 192 | 192 | return $this->inputStub[$uiType]; |
| 193 | 193 | } |
| 194 | 194 | else { |
| 195 | - $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html'); |
|
| 195 | + $this->inputStub[$uiType] = File::get($this->stubsDirectory.'Register/'.CamelCase::convertToCamelCase($uiType).'.html'); |
|
| 196 | 196 | |
| 197 | 197 | return $this->inputStub[$uiType]; |
| 198 | 198 | } |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function getOutputFilename() |
| 208 | 208 | { |
| 209 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
| 209 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/'; |
|
| 210 | 210 | |
| 211 | 211 | Directory::createIfNotExists($folder, 0755, true); |
| 212 | 212 | |
| 213 | - return $folder .$this->modelData->tableName . '_register.html'; |
|
| 213 | + return $folder.$this->modelData->tableName.'_register.html'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | \ No newline at end of file |
@@ -153,10 +153,11 @@ discard block |
||
| 153 | 153 | $inputValidations = '' ; |
| 154 | 154 | |
| 155 | 155 | foreach ($validationsConverted as $attribute => $value) { |
| 156 | - if($value) |
|
| 157 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 158 | - else |
|
| 159 | - $inputValidations .= ' '.$attribute ; |
|
| 156 | + if($value) { |
|
| 157 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 158 | + } else { |
|
| 159 | + $inputValidations .= ' '.$attribute ; |
|
| 160 | + } |
|
| 160 | 161 | } |
| 161 | 162 | |
| 162 | 163 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
@@ -177,21 +178,19 @@ discard block |
||
| 177 | 178 | |
| 178 | 179 | if($field->index == 'primary'){ |
| 179 | 180 | $uiType = 'primary' ; |
| 180 | - } |
|
| 181 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 182 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 183 | - $uiType = 'foreign_eager' ; |
|
| 184 | - else |
|
| 185 | - $uiType = $field->type->ui ; |
|
| 186 | - } |
|
| 187 | - else { |
|
| 181 | + } elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 182 | + if(isset($field->foreignKey->eager) && $field->foreignKey->eager) { |
|
| 183 | + $uiType = 'foreign_eager' ; |
|
| 184 | + } else { |
|
| 185 | + $uiType = $field->type->ui ; |
|
| 186 | + } |
|
| 187 | + } else { |
|
| 188 | 188 | $uiType = $field->type->ui ; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | if(array_key_exists($uiType, $this->inputStub)){ |
| 192 | 192 | return $this->inputStub[$uiType]; |
| 193 | - } |
|
| 194 | - else { |
|
| 193 | + } else { |
|
| 195 | 194 | $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html'); |
| 196 | 195 | |
| 197 | 196 | return $this->inputStub[$uiType]; |