Mercurial > packages > magicforger
comparison src/Generator/BaseGenerator.php @ 5:b0b2e79ad8e6
Not exatly sure what was changed but commiting to it :)
| author | luka |
|---|---|
| date | Thu, 12 Oct 2023 19:41:04 -0400 |
| parents | a20439b1c9d3 |
| children | 769a17898cc0 |
comparison
equal
deleted
inserted
replaced
| 4:a20439b1c9d3 | 5:b0b2e79ad8e6 |
|---|---|
| 9 use Symfony\Component\Console\Attribute\AsCommand; | 9 use Symfony\Component\Console\Attribute\AsCommand; |
| 10 use Symfony\Component\Console\Input\InputInterface; | 10 use Symfony\Component\Console\Input\InputInterface; |
| 11 use Symfony\Component\Console\Input\InputOption; | 11 use Symfony\Component\Console\Input\InputOption; |
| 12 use Symfony\Component\Console\Output\OutputInterface; | 12 use Symfony\Component\Console\Output\OutputInterface; |
| 13 | 13 |
| 14 use Wizzard\MagicForger\Generator\Replacer; | 14 use Wizzard\MagicForger\Replacer\Replacer; |
| 15 | 15 |
| 16 abstract class BaseGenerator extends GeneratorCommand | 16 abstract class BaseGenerator extends GeneratorCommand |
| 17 { | 17 { |
| 18 use Replacer; | 18 use Replacer; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * The console command description. | 21 * The schema of the database. |
| 22 * | 22 * |
| 23 * @var string | 23 * @var string |
| 24 */ | 24 */ |
| 25 protected $schema; | 25 protected $schema; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * The console command description. | 28 * The tables available in the schema. |
| 29 * | 29 * |
| 30 * @var string | 30 * @var array |
| 31 */ | 31 */ |
| 32 protected $tables; | 32 protected $tables; |
| 33 | |
| 34 /** | |
| 35 * The current Table being used. | |
| 36 * | |
| 37 * @var table | |
| 38 */ | |
| 39 protected $currentTable; | |
| 33 | 40 |
| 34 /** | 41 /** |
| 35 * Execute the console command. | 42 * Execute the console command. |
| 36 */ | 43 */ |
| 37 public function handle() | 44 public function handle() |
| 157 | 164 |
| 158 //Working with a stub | 165 //Working with a stub |
| 159 return $this->files->get($this->getStub()); | 166 return $this->files->get($this->getStub()); |
| 160 } | 167 } |
| 161 | 168 |
| 169 | |
| 162 /** | 170 /** |
| 163 * Get the desired class table from the input. | 171 * Get the desired class table from the input. |
| 164 * | 172 * |
| 165 * @return string | 173 * @return string |
| 166 */ | 174 */ |
| 207 $this->schema = DB::connection()->getDoctrineSchemaManager(); | 215 $this->schema = DB::connection()->getDoctrineSchemaManager(); |
| 208 } | 216 } |
| 209 | 217 |
| 210 return $this->schema; | 218 return $this->schema; |
| 211 } | 219 } |
| 220 | |
| 221 protected function getTable(string $table_name) | |
| 222 { | |
| 223 return $this->getSchema()->introspectTable($table_name); | |
| 224 } | |
| 225 | |
| 226 protected function getCurrentTable() | |
| 227 { | |
| 228 return $this->currentTable; | |
| 229 } | |
| 230 | |
| 231 protected function setCurrentTable(string $table_name) | |
| 232 { | |
| 233 $table = null; | |
| 234 if(!is_null($table_name) && trim($table_name) !== '') { | |
| 235 $table = $this->getTable($table_name); | |
| 236 } | |
| 237 $this->currentTable = $table; | |
| 238 } | |
| 212 } | 239 } |
