comparison src/Generator/Controller/ControllerGenerator.php @ 7:769a17898cc0

Various changes to the generators and replacers - probably mostly just formatting
author luka
date Wed, 18 Oct 2023 21:04:11 -0400
parents b0b2e79ad8e6
children d4730c14806d
comparison
equal deleted inserted replaced
6:b46922d4a301 7:769a17898cc0
2 2
3 namespace Wizzard\MagicForger\Generator\Controller; 3 namespace Wizzard\MagicForger\Generator\Controller;
4 4
5 use Symfony\Component\Console\Attribute\AsCommand; 5 use Symfony\Component\Console\Attribute\AsCommand;
6 use Wizzard\MagicForger\Generator\BaseGenerator; 6 use Wizzard\MagicForger\Generator\BaseGenerator;
7 use Illuminate\Support\Str;
8 7
9 #[AsCommand(name: 'mf:controller')] 8 #[AsCommand(name: 'mf:controller')]
10 class ControllerGenerator extends BaseGenerator 9 class ControllerGenerator extends BaseGenerator
11 { 10 {
12 /** 11 /**
33 /** 32 /**
34 * Execute the console command. 33 * Execute the console command.
35 */ 34 */
36 public function handle() 35 public function handle()
37 { 36 {
38 $table = $this->getTable($this->getTableInput()); 37 $this->setCurrentTable($this->getTableInput());
39 parent::handle(); 38 parent::handle();
40 } 39 }
41 40
42 /** 41 /**
43 * Get the stub file for the generator. 42 * Get the stub file for the generator.
50 } 49 }
51 50
52 /** 51 /**
53 * Resolve the fully-qualified path to the stub. 52 * Resolve the fully-qualified path to the stub.
54 * 53 *
55 * @param string $stub 54 * @param string $stub
55 *
56 * @return string 56 * @return string
57 */ 57 */
58 protected function resolveStubPath($stub) 58 protected function resolveStubPath($stub)
59 { 59 {
60 return is_file($customPath = $this->laravel->basePath(trim($stub, '/'))) 60 return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
72 * 72 *
73 * @return string 73 * @return string
74 */ 74 */
75 protected function getPath($name = null) 75 protected function getPath($name = null)
76 { 76 {
77 return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace() . '/' . $this->controller_name($this->getTableInput()) . '.php'); 77 return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php');
78 } 78 }
79 } 79 }