| Total Complexity | 7 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ScaffoldGeneratorCommand extends BaseCommand |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The console command name. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $name = 'artomator:scaffold'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The console command description. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $description = 'Create a full CRUD views for given model'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create a new command instance. |
||
| 26 | */ |
||
| 27 | public function __construct() |
||
| 28 | { |
||
| 29 | parent::__construct(); |
||
| 30 | |||
| 31 | $this->commandData = new CommandData($this, CommandData::$COMMAND_TYPE_SCAFFOLD); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Execute the command. |
||
| 36 | * |
||
| 37 | * @return void |
||
| 38 | */ |
||
| 39 | public function handle() |
||
| 40 | { |
||
| 41 | parent::handle(); |
||
| 42 | |||
| 43 | if ($this->checkIsThereAnyDataToGenerate()) { |
||
| 44 | $this->generateCommonItems(); |
||
| 45 | |||
| 46 | $this->generateScaffoldItems(); |
||
| 47 | |||
| 48 | $this->performPostActionsWithMigration(); |
||
| 49 | } else { |
||
| 50 | $this->commandData->commandInfo('There are not enough input fields for scaffold generation.'); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Get the console command options. |
||
| 56 | * |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | public function getOptions() |
||
| 60 | { |
||
| 61 | return array_merge(parent::getOptions(), []); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get the console command arguments. |
||
| 66 | * |
||
| 67 | * @return array |
||
| 68 | */ |
||
| 69 | protected function getArguments() |
||
| 70 | { |
||
| 71 | return array_merge(parent::getArguments(), []); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Check if there is anything to generate. |
||
| 76 | * |
||
| 77 | * @return bool |
||
| 78 | */ |
||
| 79 | protected function checkIsThereAnyDataToGenerate() |
||
| 83 | } |
||
| 84 | } |
||
| 85 | } |
||
| 86 |