annotate src/Generator/Route/RouteGenerator.php @ 20:81a76472ba21 main-dev

More namespace issues
author Luka Sitas <sitas.luka.97@gmail.com>
date Wed, 26 Feb 2025 19:29:55 -0500
parents 769a17898cc0
children 827efbf4d73c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
1 <?php
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
2
20
81a76472ba21 More namespace issues
Luka Sitas <sitas.luka.97@gmail.com>
parents: 7
diff changeset
3 namespace Wizard\MagicForger\Generator\Route;
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
4
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
5 use Symfony\Component\Console\Attribute\AsCommand;
20
81a76472ba21 More namespace issues
Luka Sitas <sitas.luka.97@gmail.com>
parents: 7
diff changeset
6 use Wizard\MagicForger\Generator\BaseGenerator;
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
7
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
8 #[AsCommand(name: 'mf:routes')]
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
9 class RouteGenerator extends BaseGenerator
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
10 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
11 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
12 * The name and signature of the console command.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
13 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
14 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
15 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
16 protected $name = 'mf:routes';
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
17
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
18 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
19 * The console command description.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
20 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
21 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
22 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
23 protected $description = 'Generates the Route File for a table.';
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
24
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
25 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
26 * The type of class being generated.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
27 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
28 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
29 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
30 protected $type = 'Route';
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
31
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
32 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
33 * Execute the console command.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
34 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
35 public function handle()
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
36 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
37 parent::handle();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
38 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
39
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
40 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
41 * Get the stub file for the generator.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
42 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
43 * @return string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
44 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
45 protected function getStub()
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
46 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
47 return $this->resolveStubPath('/stubs/routes.stub');
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
48 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
49
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
50 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
51 * Resolve the fully-qualified path to the stub.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
52 *
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
53 * @param string $stub
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
54 *
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
55 * @return string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
56 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
57 protected function resolveStubPath($stub)
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
58 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
59 return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
60 ? $customPath
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
61 : __DIR__.$stub;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
62 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
63
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
64 protected function getClassName($name)
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
65 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
66 return $this->routes_name($name);
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
67 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
68
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
69 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
70 * Get the stub file for the generator.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
71 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
72 * @return string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
73 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
74 protected function getPath($name = null)
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
75 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
76 return str_replace(['App\\', '\\'], ['app/', '/'], $this->getRouteNamespace().'/'.$this->routes_name($this->getTableInput()).'.php');
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
77 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
78 }