Mercurial > packages > magicforger
comparison src/Generator/View/IndexViewGenerator.php @ 25:1a717c7b211f codex
added support for some basic views
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Sun, 11 May 2025 21:03:51 -0400 |
| parents | |
| children | 555bfaa500ac |
comparison
equal
deleted
inserted
replaced
| 24:31109c61ce02 | 25:1a717c7b211f |
|---|---|
| 1 <?php | |
| 2 | |
| 3 namespace Wizard\MagicForger\Generator\View; | |
| 4 | |
| 5 use Symfony\Component\Console\Attribute\AsCommand; | |
| 6 use Wizard\MagicForger\Generator\BaseGenerator; | |
| 7 | |
| 8 #[AsCommand(name: 'mf:index_view')] | |
| 9 class IndexViewGenerator extends BaseGenerator | |
| 10 { | |
| 11 /** | |
| 12 * The name and signature of the console command. | |
| 13 * | |
| 14 * @var string | |
| 15 */ | |
| 16 protected $name = 'mf:index_view'; | |
| 17 | |
| 18 /** | |
| 19 * The console command description. | |
| 20 * | |
| 21 * @var string | |
| 22 */ | |
| 23 protected $description = 'Generates the IndexView File for a table.'; | |
| 24 | |
| 25 /** | |
| 26 * The type of class being generated. | |
| 27 * | |
| 28 * @var string | |
| 29 */ | |
| 30 protected $type = 'IndexView'; | |
| 31 | |
| 32 /** | |
| 33 * Execute the console command. | |
| 34 */ | |
| 35 public function handle() | |
| 36 { | |
| 37 parent::handle(); | |
| 38 } | |
| 39 | |
| 40 /** | |
| 41 * Get the stub file for the generator. | |
| 42 * | |
| 43 * @return string | |
| 44 */ | |
| 45 protected function getStub() | |
| 46 { | |
| 47 return $this->resolveStubPath('/stubs/index.stub'); | |
| 48 } | |
| 49 | |
| 50 /** | |
| 51 * Resolve the fully-qualified path to the stub. | |
| 52 * | |
| 53 * @param string $stub | |
| 54 * @return string | |
| 55 */ | |
| 56 protected function resolveStubPath($stub) | |
| 57 { | |
| 58 return is_file($customPath = $this->laravel->basePath(trim($stub, '/'))) | |
| 59 ? $customPath | |
| 60 : __DIR__.$stub; | |
| 61 } | |
| 62 | |
| 63 protected function getClassName($name) | |
| 64 { | |
| 65 return $this->index_view_name($name); | |
| 66 } | |
| 67 | |
| 68 /** | |
| 69 * Get the stub file for the generator. | |
| 70 * | |
| 71 * @return string | |
| 72 */ | |
| 73 protected function getPath($name = null) | |
| 74 { | |
| 75 return str_replace(['Resources\\', '\\'], ['resources/', '/'], $this->getViewNamespace($this->getTableInput()).'index.blade.php'); | |
| 76 } | |
| 77 } |
