Mercurial > packages > magicforger
diff src/Generator/Controller/ControllerGenerator.php @ 34:f65ab84ee47f default
merge with codex
| author | luka |
|---|---|
| date | Wed, 10 Sep 2025 21:00:47 -0400 |
| parents | 827efbf4d73c |
| children |
line wrap: on
line diff
--- a/src/Generator/Controller/ControllerGenerator.php Sat Dec 02 10:20:32 2023 -0500 +++ b/src/Generator/Controller/ControllerGenerator.php Wed Sep 10 21:00:47 2025 -0400 @@ -1,9 +1,9 @@ <?php -namespace Wizzard\MagicForger\Generator\Controller; +namespace Wizard\MagicForger\Generator\Controller; use Symfony\Component\Console\Attribute\AsCommand; -use Wizzard\MagicForger\Generator\BaseGenerator; +use Wizard\MagicForger\Generator\BaseGenerator; #[AsCommand(name: 'mf:controller')] class ControllerGenerator extends BaseGenerator @@ -32,47 +32,46 @@ /** * Execute the console command. */ - public function handle() + public function handle(): void { parent::handle(); } /** * Get the stub file for the generator. - * - * @return string */ - protected function getStub() + protected function getStub(): string { return $this->resolveStubPath('/stubs/controller.stub'); } /** * Resolve the fully-qualified path to the stub. - * - * @param string $stub - * - * @return string */ - protected function resolveStubPath($stub) + protected function resolveStubPath(string $stub): string { - return is_file($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__.$stub; + $customPath = $this->laravel->basePath(trim($stub, '/')); + + return is_file($customPath) ? $customPath : __DIR__.$stub; } - protected function getClassName($name) + /** + * Get the path for the generated file. + */ + protected function getPath($name = null) + { + return str_replace( + ['App\\', '\\'], + ['app/', '/'], + $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php' + ); + } + + /** + * Get the class name for the controller. + */ + protected function getClassName(string $name): string { return $this->controller_name($name); } - - /** - * Get the stub file for the generator. - * - * @return string - */ - protected function getPath($name = null) - { - return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php'); - } }
