Mercurial > packages > magicforger
comparison examples/ExampleGenerator.php.stub @ 3:6468684362c2
It works! Created a controller, no update insert but it works
| author | luka |
|---|---|
| date | Tue, 27 Jun 2023 15:32:47 -0400 |
| parents | cf9993c5c7df |
| children | a20439b1c9d3 |
comparison
equal
deleted
inserted
replaced
| 2:cf9993c5c7df | 3:6468684362c2 |
|---|---|
| 37 /** | 37 /** |
| 38 * Execute the console command. | 38 * Execute the console command. |
| 39 */ | 39 */ |
| 40 public function handle() | 40 public function handle() |
| 41 { | 41 { |
| 42 | 42 parent::handle(); |
| 43 | |
| 44 // First we need to ensure that the table exists, then we can | |
| 45 if (! $this->tableExists($this->getTableInput())) { | |
| 46 $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.'); | |
| 47 | |
| 48 return false; | |
| 49 } | |
| 50 | |
| 51 $name = $this->qualifyClass($this->getTableInput()); | |
| 52 | |
| 53 $path = $this->getPath($name); | |
| 54 | |
| 55 $file = $this->getFile($name); | |
| 56 | |
| 57 // Next, we will generate the path to the location where this class' file should get | |
| 58 // written. Then, we will build the class and make the proper replacements on the | |
| 59 // file so that it gets the correctly formatted namespace and class name. | |
| 60 $this->makeDirectory($path); | |
| 61 | |
| 62 $this->files->put($path, $this->sortImports($this->buildClass($name))); | |
| 63 | |
| 64 $info = $this->type; | |
| 65 | |
| 66 if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { | |
| 67 if ($this->handleTestCreation($path)) { | |
| 68 $info .= ' and test'; | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 $this->components->info(sprintf('%s [%s] created successfully.', $info, $path)); | |
| 73 } | 43 } |
| 74 | 44 |
| 75 /** | 45 /** |
| 76 * Get the stub file for the generator. | 46 * Get the stub file for the generator. |
| 77 * | 47 * |
